Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to fix rounding bug
Message
De
04/10/2007 04:46:33
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01258001
Message ID:
01258432
Vues:
22
>You can create your own function RoundEx and do global replace for 'ROUND(' with 'RoundEx('.
>
>* Sample code, no error handling or parameters checking
>FUNCTION RoundEx(tnNumber, tnRoundTo)
>RETURN ROUND(ROUND(tnnumber, tnRoundTo+2), tnRoundTo)
>
Thank you.
CREATE CURSOR test( KOGUS   N(12,4), KAUBASUMMA N(15,5), kogpak n(9,4) )
INSERT INTO test VALUES ( 1, 5.51031, 16 )
MESSAGEBOX( ROUND( ROUND(kogus*kogpak*kaubasumma,4),2) )
Observed: 88.17
Expected: 88.16

So ROUND( ,4) is not solution.
Round(,5) work in both cases. However, it may work in some other cases.
So round(, n+x) is not solution.

Any idea how to fix this ?
How to create function which rounds properly ?
SBT wrote white paper about VFP rounding bugs and they wrote custom rounding function in FLL. However I do'nt remember where to find this.
Andrus
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform