1.090516455488E9 / 1000000.000 ???
Nick Craig-Wood
nick at craig-wood.com
Tue Mar 28 10:30:05 EST 2006
Math <mathweijzen at home.nl> wrote:
> I got a simple and probably stupid newby question..
> When I compute:
> 1.090516455488E9 / 1000000
> the result is 1090516455.49
> Should be 1090516455.488
>
> I know something with float and //...
http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate
Eg
>>> a=1.090516455488E9 / 1000000
>>> print a
1090.51645549
>>> print repr(a)
1090.516455488
>>>
If you want a given number of decimal places you can use a formatter,
eg
>>> print "%.20f" % a
1090.51645548800001961354
--
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick
More information about the Python-list
mailing list