Decimal arithmetic, was Re: Python GUI app to impress the boss?
Steve Holden
sholden at holdenweb.com
Wed Oct 2 10:04:20 EDT 2002
"Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in message
news:mailman.1033528684.23114.python-list at python.org...
> ----- 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:
>
> "Classic" rounding:
> >= 0.5 (units) up, < 0.5 down
>
> "Banker's" rounding:
> > 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.
>
Then there's what I'll call "numerical analyst's rounding", intended to
remove the bias of always rounding the same way at the boundary. I may be
wrong here; I took the classes in 1973 ....
> 0.5 (units) round away from zero,
< 0.5 round towards zero
= 0.5: round towards zero if next most significant digit is odd,
otherwise away from zero.
regards
-----------------------------------------------------------------------
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/pwp/
Previous .sig file retired to www.homeforoldsigs.com
-----------------------------------------------------------------------
More information about the Python-list
mailing list