Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VFP 7 Round() Bug ???
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00701203
Message ID:
00701273
Views:
17
>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.
Previous
Reply
Map
View

Click here to load this message in the networking platform