floating point woes

André Roberge andre.roberge at gmail.com
Tue Feb 15 19:03:03 EST 2011


On Tuesday, February 15, 2011 7:49:34 PM UTC-4, Hans-Peter Jansen wrote:
> Hi,
> 
> while I usually cope with the woes of floating point issues, this is 
> one, that I didn't expect:
> 
> >>> round(2.385, 2)
> 2.3799999999999999
> 
> Doesn't the docs say, it's rounded up for this case?

The problem is probably that 2.385 can not be represented as 2.385000000000....

>>> a = 2.385
>>> a
2.3849999999999998

André
> 
> <quote>
> Values are rounded to the closest multiple of 10 to the power minus n; 
> if two multiples are equally close, rounding is done away from 0
> </quote>
> 
> Well, that one is clearly rounding down.
> 
> What's up, eh, down here?
> 
> Pete
> 
> Python 2.6 (r26:66714, Feb  8 2011, 08:50:11) 
> [GCC 4.3.2 [gcc-4_3-branch revision 141291]] on linux2




More information about the Python-list mailing list