1.090516455488E9 / 1000000.000 ???

Math mathweijzen at home.nl
Tue Mar 28 19:57:08 CEST 2006


Thanks  this does the job
And yes,  I really need this accuracy..

Many Thanks
----- Original Message ----- 
From: "Felipe Almeida Lessa" <felipe.lessa at gmail.com>
To: "Fredrik Lundh" <fredrik at pythonware.com>
Cc: <python-list at python.org>
Sent: Tuesday, March 28, 2006 6:00 PM
Subject: Re: 1.090516455488E9 / 1000000.000 ???


> 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 




More information about the Python-list mailing list