Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Round() Function
Message
From
31/08/1998 21:35:30
 
 
To
29/08/1998 22:14:55
Thongchai Prertpornpan
Grolier International, Inc.
Bangkok, Thailand
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00131310
Message ID:
00131748
Views:
18
>I use round() in my report designer and sum the result of my report.
> Then I write program to round up the number and sum it. The result is
> not the same. I get 0.01 differential.
>>What was your observation?? You have asked a rather open-ended question...
>>
>>>Hi,
>>> Has anyone found bug in round function of Visual Foxpro 3.0?
>>>I am not sure about this. How do you think about it?

That´s a "fact of life" with rounding: if you round numbers and sum them, the answer won´t be the same that if you sum them first and round afterwards. A quick example:

ROUND(6.67,0)+ROUND(6.67,0)+ROUND(6.67,0)= 7+7+7 = 21
ROUND(6.67+6.67+6.67,0) = ROUND(20.01,0) = 20

The best answer? There isn´t any, but you could either (1) set up things so you need no rounding (for example, always store rounded numbers, so you don´t need to round again), or (2) put an alert in your report as to the fact that due to roundings, totals might not coincide.

HTH!
Previous
Reply
Map
View

Click here to load this message in the networking platform