Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
NEVER compare values with EMPTY()!!!! SERIOUS Bug!
Message
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00559148
Message ID:
00560069
Views:
23
>The Problem still is there.
>The empty() Command delivers a false while the Value itself can be compared
>with 0.
>The empty() command obviously has a bug.
>Here's the Code again.
>
>clear
>local a, b, c, d,x
>a= -1
>b= -0.1
>c= 1
>d= 0.1
>x= a+b+c+d
>? empty(x)
>? x=0 &&This should also deliver a ".f." but it gives us a .t.
>
>I think Microsoft should repair this. I understand the floating point, but I
>never suspected it in any command from FoxPro.
>
>Here's a workaround code. But I think we could instanciate every FoxPro
>command like this one if we can not dely on the behavior. Also this slows >down our programs a little bit.
>
>*proc_empty.prg
>lparameters lvValue
>if type("lvValue")="N"
> return lvValue=0
>else
> return empty(lvValue)
>endif

I'm still not convinced this is a bug, but I see your point. I'll pass it up to the product group, and see what they say.

However, the fact remains that you cannot rely on floating point values being summed to 0. ALWAYS round to the number of decimals you're using before doing a comparison. Last time I worked on accounting software, I made a point of doing this.
My blog
My consulting page
My home page

Member of the Trim Your Auto-Quote Campaign!
What's another word for thesaurus?
Previous
Reply
Map
View

Click here to load this message in the networking platform