Em Ter, 2006-03-28 às 16:59 +0200, Fredrik Lundh escreveu: > and consider using > > http://www.python.org/doc/lib/module-decimal.html > > instead.
$ python2.4 Python 2.4.2 (#2, Nov 20 2005, 17:04:48) [GCC 4.0.3 20051111 (prerelease) (Debian 4.0.2-4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from decimal import Decimal >>> a = Decimal("1.090516455488E15") >>> a Decimal("1.090516455488E+15") >>> b = a / 1000000 >>> b Decimal("1090516455.488") >>> str(b) '1090516455.488' *But*, $ python2.4 -mtimeit -s 'from decimal import Decimal; a = Decimal("1.090516455488E15")' 'a/1000000' 1000 loops, best of 3: 222 usec per loop $ python2.4 -mtimeit -s 'a=1.090516455488E15' 'a/1000000' 1000000 loops, best of 3: 0.234 usec per loop $ calc 222/0.234 ~948.71794871794871794872 Decimal is almost one thousand times slower. Do you really need this accuracy? HTH, -- Felipe. -- http://mail.python.org/mailman/listinfo/python-list