Decimal can be Binary Too (was decimal or rational)

Tim Peters tim.one at home.com
Mon Jun 4 21:45:38 EDT 2001


[Don O'Donnell]
> ...
> Do you think it would be possible or desirable to extend/generalize
> your FixedPoint class to handle the "floating decimal" as an option?
> Or would it be better to make it a separate class or subclass?  Any
> opinions?

Sorry to skip most of the text, but I'm very short on time tonight.  The
short and the long course is that I don't want Python to reinvent this wheel
yet again, so have been arguing for serious consideration of IBM's Standard
Decimal Arithmetic proposal:

    http://www2.hursley.ibm.com/decimal/

Floating decimal is very much a part of that.  Aahz is in the process of
implementing it as a Python module; see his Decimal.py at

    http://starship.python.net/crew/aahz/

If, after (it's not done yet) people get to kick Decimal's tires, they're
happy (OK, I'll settle for happier <wink>) with this approach, Aahz has been
writing in it such a way that the performance-critical parts can be migrated
to C easily.  If not, hey -- it's Python!  It's painless to throw away (and
especially if you're not Aahz <wink>).

> still-learning-from-reading-your-code-ly y'rs

Ah, in *that* case, FixedPoint.py does way too many magical coercions, the
test suite should be 100x larger, and I'm not sure the intent of seemingly
tautological comments like

        # n1/10**p / (n2/10**p) = n1/n2 = (n1*10**p/n2)/10**p

is obvious to anyone but me -- but you got what you paid for <wink>.





More information about the Python-list mailing list