code not true?

Lloyd Zusman ljz at asfast.com
Sun Apr 23 12:01:19 EDT 2000


"Gordon McMillan" <gmcm at hypernet.com> writes:

> [ ... ]
> 
> The theoretically correct alternative is rationals. But they're 
> slow and use unpredictable amounts of memory. I think 
> Python should have BCD as an alternative. While slow, they're 
> predictable in memory use, and the mathematical 
> shortcomings they have are exactly those that a naive user 
> expects.

Python already has unlimited-precision long integers as part of the
language, and the `mpz' module that comes with the standard Python
release is another multiple-precesion option (built on top of GNU MP).
See sections 2.1.4 ("Numeric Types") and 15.2 ("mpz") of the Python
Library Reference manual.

It should be fairly straightforward to use the unlimited-precision
long integers or `mpz' to implement a BCD module that handles decimal
arithmetic and not just integer math.

Ages ago I wrote an unlimited-precision BCD math library in C ... I'm
sure I could do it again (and much more easily and quickly) in Python.

Then again, I'd hate to re-invent the wheel ... I'd be surprised if
someone hasn't already created such a thing in Python ... ???


> [ ... ]
> 
> - Gordon

-- 
 Lloyd Zusman
 ljz at asfast.com



More information about the Python-list mailing list