[Python-Dev] rounding problem
Skip Montanaro
skip at pobox.com
Mon May 31 22:01:55 EDT 2004
Norlin> the number actually comes from multiplication between 237.50 and
Norlin> 4.762 which will get 1130.975. So it suppose to be 1130.98 isnt
Norlin> it if it'll get rounded to 2 decimal places.
Nope. 1130.975 is not exactly representable. In fact, it's internal
representation is slightly less that 1130.975, so rounding to two decimal
places is correctly 1130.97.
% python
Python 2.4a0 (#25, May 22 2004, 15:16:21)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 1130.975
1130.9749999999999
Skip
More information about the Python-Dev
mailing list