views:

394

answers:

3

It's 123.98699999999999 !

Why is that?


Thanks guys! :)

+6  A: 

The Python FAQ and tutorial address this issue pretty well, I think. More generally, both are excellent resources, well worth your time to browse if you have any interest in Python!-)

Alex Martelli
that was very useful thanks!
RadiantHex
+2  A: 

This has changed in/since Python 3.1.

See also: issue 1580


To your (already deleted) addition: Use the decimal package.

Debilski
The conversion of float to string has changed, but not the conversion from string to float.
dan04
@dan04: What do you mean? `float('0.2') == float(0.2)`
Debilski
@Debilski: `repr(0.2)` used to be `'0.20000000000000001'`. Now it's just `'0.2'`.
dan04