Tim Roberts <[EMAIL PROTECTED]> writes:
> "Math" <[EMAIL PROTECTED]> 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
--
http://mail.python.org/mailman/listinfo/python-list