Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.
Originally posted by: timonkZon,
You have stumbled upon a rather amusing case of how the system is representing numbers internally.
Take a look at the Python terminal output below:
Python 2.4.4 (#71, Oct 18 2006, 08:34:43) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.39776
0.39776
>>> 0.39775
0.39774999999999999
Internally, 0.39776 is actually just that. So when you do a round() operation on it, you get 0.3978. However, the internal binary for 0.39775 is actually valued at 0.39774999... So when you do the round() on it, the result appears be off by one.
If you had happened to pick 0.29775, or 0.19775, or 0.49775, you would have been fine:
>>> 0.19775
0.19775000000000001
>>> 0.29775
0.29775000000000001
>>> 0.49775
0.49775000000000003
>>>
Regards
Timon Koufopoulos
MDA Support.