Against PEP 240

Aahz Maruch aahz at panix.com
Sat Jun 2 21:56:47 EDT 2001


In article <mailman.991515668.4621.python-list at python.org>,
Tim Peters <tim.one at home.com> wrote:
>[Roman Suzi]
>> This said, what is the right way to deal with>currencies in Python
>> right now?
>
>[Aahz]
>> Tim Peters's FixedPoint.py:
>>
>>
><ftp://ftp.python.org/pub/python/contrib-09-Dec-1999/DataStructures/FixedPoi
>nt.py>
>>
>> You *probably* want to set the precision to three or four places
>> so that rounding errors don't propagate.
>
>Hmm.  It's important to note that + and - on FixedPoints never suffer
>rounding errors.  Add up, say, a million dollars-and-cents FixedPoint
>quantities each of precision 2, and the computed result is *exactly*
>correct.  The problems with using binary f.p. in "the naive" way for
>financial calcuations only start with that most dollars-and-cents inputs
>can't be represented exactly; subsequent additions are also subject to
>rounding errors; FixedPoint suffers neither problem.

Right.  I was assuming because of the plural that Roman was likely to
want to do currency conversions, which involves multiplication at the
very least.
-- 
                      --- Aahz  <*>  (Copyright 2001 by aahz at pobox.com)

Androgynous poly kinky vanilla queer het Pythonista   http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

I surf faster than you do, monkey boy.  (My take on Netscape vs. Lynx)



More information about the Python-list mailing list