In article <i41p6e$1f...@dough.gmane.org>, Christian Heimes <li...@cheimes.de> wrote: >> Is there a way I can keep my floating point number as I typed it? For >> example, I want 34.52 to be 34.52 and NOT 34.5200000002. > This isn't a Python issue. Python uses IEEE 754 [1] double precision > floats like most other languages. 34.52 can't be stored in a float. The > next valid float is 34.5200000002.
Well, it is a *bit* of a Python issue since, as others have pointed out, Python's behavior has changed due to the implementation of Gay's rounding algorithm in 3.1 and also in 2.7: $ python2.6 -c 'print(repr(34.52))' 34.520000000000003 $ python2.7 -c 'print(repr(34.52))' 34.52 $ python3.1 -c 'print(repr(34.52))' 34.52 -- Ned Deily, n...@acm.org -- http://mail.python.org/mailman/listinfo/python-list