Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How You deal with VFP Rounding BUG
Message
De
24/11/2007 03:21:35
 
 
À
23/11/2007 18:07:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01270811
Message ID:
01271010
Vues:
24
>>Hi Vladimir,
>>
>>>I am interesting in what is the best practice to deal with VFP rounding in calculation proble.
>>
>>Actually, this has nothing to do with rounding. The problem is that 550000.815 is not a number you can store in a floating point value which uses a base of 2. That's the same as trying to display 2/3 accurately with a base of 10. You can see this without any multiplication and rounding by just printing:
>>
>>? 550000.8150000000000000000000000000
>>
>
>Ok I understand that but, try above examples or rounding problems in VB or C# and they work like they should. So something is wrong with VFP definitely.

VFP has bugs in:
1. literal conversion to float
2. ROUND() routine
3. STR() routine
...

On this case:
the corect float binary for 550000.815 is 0h4120C8E1A147AE15
but VFP put in memory a wrong float binary value
CLEAR
? "WRONG",0h+BINTOC(550000.815,"BR")
? "WRONG",0h+BINTOC(550000.000+.815,"BR")
? "if you split the decimal part, then VFP put the exact binary"
? "CORRECT",0h+BINTOC(550000.810+0.005,"BR")
? "CORRECT",0h+BINTOC(550000.000+.800+0.015,"BR")
? "CORRECT",0h+BINTOC(550000.005+0.810,"BR")
? "CORRECT",0h+BINTOC(550000.805+0.010,"BR")
In VB, C#, C, T-SQL the parser put the crrect binary floating point value.

The fact remains that both binary values are not 550000.815 exactly.

Fabio
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform