Decimal arithmetic, was Re: Python GUI app to impress the boss?

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Wed Oct 2 23:12:51 EDT 2002


----- Original Message -----
From: "Steve Holden" <sholden at holdenweb.com>


> "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> wrote in
message
> news:mailman.1033528684.23114.python-list at python.org...

> > 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.

Hmm.  Given 5.5, rounding towards 0 would be 5.0, right?
So this is the exact opposite of Banker's rounding...
effectively rounding to an odd rather than even unit value.

I'm beginning to understand Tim's annoyance.

Chris Gonnerman -- chris.gonnerman at newcenturycomputers.net
http://newcenturycomputers.net





More information about the Python-list mailing list