Hi!
>That's certainly an interesting problem. It seems the problem is not the empty function (at least when I ran the test) but that the sum of floating point numbers gives you unexpected (to me at least) results. lnValue is not empty on my computer -- its 0.00000...07. Or maybe it's not so unexpected if you think about the way floating point numbers are represented.
>
Exactly.
>By the way changing set fixed and set decimal didn't change the problem. By changing set fixed on and set decimal to 2, lnValue was displayed properly, but empty() still treated it as a non-0 value. Again if you think about how floating numbers are represented then it's clear why the results depend upon the order of the sum calculation.
>
>Empty is meant for character values it seems!
>
No. there are empty date value. Integer 0 is also an empty value. Though compatison like 'Value=0' works more quickly, so I do not use empty() anyway even for strings.
>>*Hi FoxPro users!
>>*We have found a serious Problem with the EMPTY() comparison.
>>*The Code Sample uses a CURSOR Table, but you dont have to!
>>*You could also use the values in variables
>>
>>local lnValue
>>create cursor Test(value n(10,2))
>>select test
>>**Append Values in exactly this Order
>>append blank
>>replace value with 260.70
>>append blank
>>replace value with -31.60
>>append blank
>>replace value with -260.70
>>append blank
>>replace value with 31.60
>>lnValue = 0
>>select test
>>scan
>> lnValue=lnValue+value
>>endscan
>>wait window "Empty="+transform(empty(lnValue));
>> +" ; lnValue="+transform(lnValue);
>> +" ; Comparison on lnVALUE=0 is "+transform(lnValue=0) && This Value should be Empty()! But it isn't!
>>
>>*Serious Problem!
>>*But when you have the Table values in this Order
>>*260.70
>>*-260.70
>>*-31.60
>>*31.60
>>*
>>*or this order
>>*
>>*260.70
>>*31.60
>>*-31.60
>>*-260.70
>>*
>>*it gives you the correct empty=.t.
>>
>>*Same Problem with the Order of values
>>*260.70
>>*31.60
>>*-260.70
>>*-31.60
>>
>>*This Causes an error which is not displayed in transform
>>*1
>>*-0.1
>>*-1
>>*0.1
>>*The difference is in the 37 Comma Digit of the value
>>*This means for us.... we have to create an ORDER on every VALUE we want to ADD
>>*
>>*OR
>>*
>>*Never Compare a Value with empty() !!!!
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.comICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs
It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.