Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP 7 Round() Bug ???
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00701203
Message ID:
00701273
Vues:
18
>There is a bug with round() Has anyone see this ? Is there a workaround ?
>
>
?Round(.425*429.4, 2)
*--Display 182.50

?Round(.425000*429.400000, 2)
*--Display 182.49
>

This is a documented bug. See KB article Q157954. The suggested workaround is to use the currency data type. In my experience, for best accuracy, convert all currency data types to numeric with MTON before performing calculations, then convert back to currency with NTOM, if desired, before rounding. The following all produce the correctly rounded result in VFP 7.0 SP1:
* If currency data type result is desired
?ROUND( NTOM( MTON( $.425000) * MTON( $429.400000)), 2)  && 182.5000
?ROUND( NTOM( MTON( $.425) * MTON( $429.4)), 2)  && 182.5000

* If numeric data type result is desired
?ROUND( MTON( $.425000) * MTON( $429.400000), 2)  && 182.50
?ROUND( MTON( $.425) * MTON( $429.4), 2)  && 182.50
Rick Borup, MCSD

recursion (rE-kur'-shun) n.
  see recursion.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform