float to str help
Skip Montanaro
skip at pobox.com
Thu Jul 19 11:44:23 EDT 2001
Bryan> In converting a float (5.661706091586558e+240) to a string using
Bryan> str() I come up with 5.6617060916+240 . I checked the string
Bryan> variable in the debugger. I need the full precicsion. I know its
Bryan> probably simple but this red hair is causing me problems.
Try repr() or string interpolation:
>>> f = 5.661706091586558e+240
>>> f
5.6617060915865581e+240
>>> str(f)
'5.66170609159e+240'
>>> repr(f)
'5.6617060915865581e+240'
>>> "%.17f" % f
'5.6617060915865581e+240'
--
Skip Montanaro (skip at pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/
More information about the Python-list
mailing list