Precise calculations
Alex Martelli
aleaxit at yahoo.com
Fri Nov 7 18:22:32 EST 2003
Ben Finney wrote:
...
>> Could anybody help me on how to do precise calculations with Python
>> the way hand-held calculators do?
>
> Use rounding, e.g. as implemented by the str() function. From the above
Use str if you really want to do like hand-held calculators, i.e., hide some
digits. If you want really high precision in binary floating point, the
gmpy extension module may be useful; if in decimal floating point, there is
a class Decimal that's being worked on to eventually provide that, too.
Alex
More information about the Python-list
mailing list