Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Rounding problem?
Message
 
 
To
20/03/2000 16:47:11
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00348122
Message ID:
00348280
Views:
16
If I remember my math , when rounding a number which is EXACTLY half way (in this case 0.0050000), the rounding rules get strange. For the round() function' I always add a five to the next decimal place to force the number to be rounded up. This removes erratic behavior of the ROUND function for numbers which fall exactly at the midpoint. For this case I would use :

ln_round = .35000000 * 943.0 *.100
ln_round = ln_round + .005 && Use .005 since we are ronding to two places
ln_round = ROUND(ln_round,2)

This will force any number which lands exactly midway to be rounded up. If you subtract .005 the midway number will be rounded down.
Ken Wardwell
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform