factorial of negative one (-1)

Hrvoje Niksic hniksic at xemacs.org
Tue Nov 2 11:11:52 CET 2010

Ken Watford <kwatford+python at gmail.com> writes:

>>>>> 1.1 .as_integer_ratio()
>> (2476979795053773, 2251799813685248)
> Handy, but if you need the exact representation, my preference is
> float.hex, which seems to be the same as C99's %a format.
> Granted, it's not as easy for humans to interpret, but it's useful for
> certain things.

Since it's used by both C99 and Java, supporting it is a nice
interoperability feature:

In fact, the float output provides educational insight of its own
because it shows rounding effects without the apparent "garbage digits"

>>> 1.1 .hex()

Here it is immediately obvious that the final digit of the infinite
sequence "1.1999..." is rounded from 9 to a.  Printing the number with
any more digits would just reveal zeros, as expected.

Does anyone know why Python doesn't accept hex float literals in source

More information about the Python-list mailing list