On Mon, Nov 1, 2010 at 5:42 AM, Hrvoje Niksic <hnik...@xemacs.org> wrote: > > Printing out further digits (without quotes) is not pointless if you > want to find out the exact representation of your number in python's > floating point, for educational purposes or otherwise. Python has a > little-known but very instructive method for determining the makeup of a > float: > >>>> 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. >>> math.pi.hex() '0x1.921fb54442d18p+1' >>> float.fromhex(math.pi.hex()) == math.pi True Granted, it's not as easy for humans to interpret, but it's useful for certain things. -- http://mail.python.org/mailman/listinfo/python-list