Floating point numbers don’t round nicely and certainly not always to the same value. Not sure what database you are using, but I leaned the hard way to use the DECIMAL datatype (MySQL) in place of FLOAT for my solutions, as floating point numbers are extremely difficult to work with when precision and rounding is important.
These floating point numbers should have at least 15 significant digits of accuracy. Rounding to 1 digit beyond the decimal point should have no problems at all.
As another example, if we set the format to just “#” (round to the nearest integer):
0.490 rounds down to 0
0.491 rounds up to 1
1.489 rounds down to 1
1.490 rounds up to 2
This is clearly wrong: anything below 0.5 should round down to 0.
Is there any way this problem can be fixed in the next release? This is a pretty significant rounding issue that i’m sure other users will also have problem with. Please help
thanks!
sammy
sammyzheng:
Thanks for fixing it. However, it looks like there is now an issue with borderline numbers rounding down when they should round up. For example:
0.5 rounds to 0 (when display format is “0”)
0.25 rounds to 0.2 (when display format is “0.0”)
Those 2 examples should definitely round up since the binary representation is exactly the same as the decimal value. Can this be fixed as well?