General information
Category:
Coding, syntax & commands
>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.
Shouldn't the operation here be truncation following addition of 0.005, otherwise this will always cause round up. Consider 1.0001, rounded to 2 dp this should be 1.00, if 0.005 is added, then calculation is round( 1.0051, 2 ) which should be 1.01, the wrong result.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only