Decimal arithmetic, was Re: Python GUI app to impress the boss?
johnroth at ameritech.net
Wed Oct 2 12:57:27 CEST 2002
"Paul Rubin" <phr-n2002b at NOSPAMnightsong.com> wrote in message
news:7x4rc5324z.fsf at ruckus.brouhaha.com...
> "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> writes:
> > What, exactly, is wrong with wanting math involving essentially
> > decimal monetary amounts to lead to proper decimal rounding? Paul
> > keeps waving bananas in my face. That's not the problem... since
> > time immemorial, grocers have had to handle three-for-a-buck sales.
> > They know how they want the math done; and adding some extra
> > precision to the intermediate steps solves Paul's complaint. So why
> > does he keep complaining?
> I'm told that a certain rounding method might not always produce the
> same answer as doing it the "right" way. So I asked for a
> algorithm for finding the "right" answer in order to compare the
> So far I haven't gotten that algorithm.
That's because there isn't one. I used to work for an insurance
company that did one-off contracts for group insurance. Each
one had specialty rounding, specified by the actuaries to make
the contract come out right. In the face of that kind of illogic, you
can't even depend on there being three rounding policies: truncate,
round at .5 and roll up any fraction. I've seen specs that require
rounding up at .70, for example.
More information about the Python-list