Decimal arithmetic again (was Re: PEP 238 (revised))
Aahz Maruch
aahz at panix.com
Sat Jul 28 23:44:57 EDT 2001
In article <rzJ87.20458$oh1.6779045 at news2.rdc2.tx.home.com>,
Rainer Deyke <root at rainerdeyke.com> wrote:
>
>'1.0' is a fixed point number with one digit to the right of the decimal
>place. '1.00' is a fixed point number with two digits to the right of the
>decimal place. '1e-1' is a fixed point number with one digit to the right
>of the decimal point. '1e1' is a fixed point number with negative one
>digits to the right of the decimal point. Conceptually, integers are fixed
>point numbers with zero digits to the right of the decimal place.
>
>Internally, each number could be represented as two integers (longs): one
>'base' and 'exp', such that the value of the number is 'base + 10 ** exp'.
>'-exp' is the number of digits to the right of the decimal point.
>
>For addition (and subtraction), the number with fewer digits to the right of
>the decimal point is padded with zeros. Addition is therefore an exact
>operation:
>
>1.00 + 1.0 => 1.00 + 1.00 => 2.00
This is precisely what I'm currently implementing as Decimal.py. You
can find my current code at http://starship.python.net/crew/aahz/
--
--- Aahz <*> (Copyright 2001 by aahz at pobox.com)
Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista
Fortune cookie: Watch your relations with other people carefully, be reserved.
More information about the Python-list
mailing list