Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Round() Function
Message
De
31/08/1998 21:35:30
 
 
À
29/08/1998 22:14:55
Thongchai Prertpornpan
Grolier International, Inc.
Bangkok, Thailande
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00131310
Message ID:
00131748
Vues:
17
>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!
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform