[Python-Dev] Revised decimal type PEP
M.-A. Lemburg
mal@lemburg.com
Wed, 01 Aug 2001 18:54:35 +0200
Guido van Rossum wrote:
>
> > Decimals are just a different way of displaying Rationals and
> > depending on their preset precision show a different behaviour
> > in numeric operations.
>
> Not necessarily. If decimals are used for (in-memory) representation,
> they can't represent all rationals.
I know, that's what I wanted to say with "depending on their preset
precision"; if you have a decimal with precision 2 then 1/3 will
come out as "0.33" -- my point was that by implementing a Rational
type instead of a decimal type we can have all semantics of decimals
by simply subclassing the Rational type.
This setup will be more flexible than choosing one of the many
different variants of "how to add two decimal numbers"
(e.g. calculator style, with hidden extra digits, with truncation,
mathematical rounding, (one of the various) financial rounding
modes, etc.).
--
Marc-Andre Lemburg
CEO eGenix.com Software GmbH
______________________________________________________________________
Consulting & Company: http://www.egenix.com/
Python Software: http://www.lemburg.com/python/