Decimal arithmetic, was Re: Python GUI app to impress the boss?
chris.gonnerman at newcenturycomputers.net
Wed Oct 2 05:19:59 CEST 2002
----- Original Message -----
From: "Tim Peters" <tim_one at email.msn.com>
> > I second Tim Peter's motion... the rounding rule should
> > be configurable on a per-application basis.
> Then please help Doug do that, including *defining* the
> rounding disciplines you think are needed; I was never able
> to bully <wink> those out of its users,
I keep hearing this... what is the problem, exactly? So far as I've ever
been taught, there are only two rules:
>= 0.5 (units) up, < 0.5 down
> 0.5 up, < 0.5 down, ties broken by rounding
to the next even unit
(units = pennies in US)
> so "banker's rounding" is the only thing that's there (it
> happens to be better for overall accuracy than biased "add
> a half and chop" rounding, so I was keener to give casual
> users something less likely to get them into trouble).
I have to agree here. This is not IMHO the "least surprising"
choice, but given two options, it's the most accurate.
> There are also difficult design decisions whenever a
> "global magic setting" is involved, including thread safety
> and what to do if different parts of an app need different
> settings (where "different parts" can include 3rd-party
> library modules you're only dimly aware of, too -- you
> can't step on what they need to happen, and neither can you
> allow them to step on what you need).
A class mixin was suggested for this; I can't think of a
> I can't make time to help with this, other than to
> point out such issues.
Granted. If I get the time I'll study the code.
Chris Gonnerman -- chris.gonnerman at newcenturycomputers.net
More information about the Python-list