Unexplained behavior 
Author Message
 Unexplained behavior

I have an array consisting of the following columns:
        column 1 = numerical value (integer) & a Symbol (string * 5)
        column 2 is an amount field (defined as currency)

         example array entries = 2005120JALMX| 43075.00
                                 2005093MUIFX|   188.21

        There can be several hundred entries

If I sort the array on the first column accumulating the amount field.
This produces a total amount of all entries.

However, if I set the Symbol portion of column 1 in  each entry to
spaces,sort on column 1 and accumulate the amounts I get a different total.

I can't understand how this could be.  Why would the sort sequence  have
any effect on the amount accumulation?

Any thoughts would be appreciated.

Mel



Tue, 10 Jul 2012 04:42:12 GMT  
 Unexplained behavior
Are you perhaps omitting the first or last entry when you get the sum. That
would cause the total to vary depending on the sort.
This kind of mistake can happen with zero based arrays.

Alternatively if you sort on the first column, get the total then sort on
the second then re-sort on the first and get the total again, is it the same
as the first time? If not there is something wrong with your sort.

Dave O.


Quote:
>I have an array consisting of the following columns:
> column 1 = numerical value (integer) & a Symbol (string * 5)
> column 2 is an amount field (defined as currency)

>         example array entries = 2005120JALMX| 43075.00
>                                 2005093MUIFX|   188.21

> There can be several hundred entries

> If I sort the array on the first column accumulating the amount field.
> This produces a total amount of all entries.

> However, if I set the Symbol portion of column 1 in  each entry to
> spaces,sort on column 1 and accumulate the amounts I get a different
> total.

> I can't understand how this could be.  Why would the sort sequence  have
> any effect on the amount accumulation?

> Any thoughts would be appreciated.

> Mel



Tue, 10 Jul 2012 18:04:52 GMT  
 Unexplained behavior
Dave, thanks for the response.

I am using the same array and same sort in both instances. The only
change is that one time the last five characters of column 1 is a stock
symbol and on the second pass the last five characters of the first
column are spaces. I am currently going to write a file of each sort
results and do a comparison on them.  Got to be something different
about them.

Marv


Quote:
> Are you perhaps omitting the first or last entry when you get the sum. That
> would cause the total to vary depending on the sort.
> This kind of mistake can happen with zero based arrays.

> Alternatively if you sort on the first column, get the total then sort on
> the second then re-sort on the first and get the total again, is it the same
> as the first time? If not there is something wrong with your sort.

> Dave O.



>> I have an array consisting of the following columns:
>> column 1 = numerical value (integer)&  a Symbol (string * 5)
>> column 2 is an amount field (defined as currency)

>>          example array entries = 2005120JALMX| 43075.00
>>                                  2005093MUIFX|   188.21

>> There can be several hundred entries

>> If I sort the array on the first column accumulating the amount field.
>> This produces a total amount of all entries.

>> However, if I set the Symbol portion of column 1 in  each entry to
>> spaces,sort on column 1 and accumulate the amounts I get a different
>> total.

>> I can't understand how this could be.  Why would the sort sequence  have
>> any effect on the amount accumulation?

>> Any thoughts would be appreciated.

>> Mel



Wed, 11 Jul 2012 01:45:52 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Unexplained Persistence

2. unexplained error

3. Unexplained Run-Time error #48

4. Unexplained "Invalid Use of Property"

5. Strange (and unexplained) error reported to event log

6. Unexplained Corruption problems of using VB And MS-Access

7. Unexplained ADO Error - .AddNew

8. Queer Query Behavior

9. Inconsistent Query Behavior

10. CBF wipes out class based behavior?

11. tab key behavior on a bound form

12. FolderExists behavior

 

 
Powered by phpBB® Forum Software