1.090516455488E9 / 1000000.000 ???
Ben Finney
bignose+hates-spam at benfinney.id.au
Wed Mar 29 05:49:23 EST 2006
Tim Roberts <timr at probo.com> writes:
> "Math" <mathweijzen at home.nl> wrote:
>>And yes, I really need this accuracy..
>
> Then you need to understand that you don't really HAVE this accuracy.
With the Decimal type, you do.
>>> import decimal
>>> decimal.getcontext().prec = 5
>>> decimal.Decimal(1) / decimal.Decimal(7)
Decimal("0.14286")
>>> decimal.getcontext().prec = 28
>>> decimal.Decimal(1) / decimal.Decimal(7)
Decimal("0.1428571428571428571428571429")
>>> decimal.getcontext().prec = 56
>>> decimal.Decimal(1) / decimal.Decimal(7)
Decimal("0.14285714285714285714285714285714285714285714285714285714")
It also survives arithmetic.
<URL:http://docs.python.org/lib/module-decimal.html>
--
\ "The cost of a thing is the amount of what I call life which is |
`\ required to be exchanged for it, immediately or in the long |
_o__) run." -- Henry David Thoreau |
Ben Finney
More information about the Python-list
mailing list