Index: Doc/tutorial/floatingpoint.rst =================================================================== --- Doc/tutorial/floatingpoint.rst (revision 66467) +++ Doc/tutorial/floatingpoint.rst (working copy) @@ -135,7 +135,22 @@ :func:`str` usually suffices, and for finer control see the :meth:`str.format` method's format specifiers in :ref:`formatstrings`. +Python provides a couple of methods that may help on those rare +occasions when you really *do* want to know the exact value of a +float. The :meth:`float.as_integer_ratio` method expresses the value +of a float as a fraction:: + >>> x = 3.14159 + >>> x.as_integer_ratio() + (3537115888337719L, 1125899906842624L) + +The :meth:`float.hex` method expresses a float in hexadecimal (base +16), again giving the exact value stored by your computer:: + + >>> x.hex() + '0x1.921f9f01b866ep+1' + + .. _tut-fp-error: Representation Error