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

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Tue Oct 1 23:00:33 EDT 2002


----- Original Message ----- 
From: "Paul Rubin" <phr-n2002b at NOSPAMnightsong.com>


> "Chris Gonnerman" <chris.gonnerman at newcenturycomputers.net> writes:
> > If this isn't a good enough definition of "right" for
> > you, please tell me what, exactly, is wrong with it.
> > What do you need to understand the problem?
> 
> We've been over this several times already.  9 bananas at
> 3 for a dollar.
> 
>    (9 * 1) / 3 = 3.00
>    9 * (1/3) = 2.97
> 
> What part of your definition of "right" says which one of
> these to choose?

OK.  You either didn't read my previous post or didn't
understand it.  The problem you are talking about is
"above" the problem I'm talking about.

The answer to the question you are asking is not
directly relevant to my problem.  I'm not complaining
about floating point arithmetic.  I'm complaining about
floating BINARY points.  BINARY, not decimal.

I don't care it it's ScaledDecimal or FixedPoint or 
freakin' IBM BCD... I just don't EVER want to see:

    0.70 * 0.05 = 0.034999...

... in a monetary application.

What you are discussing is the hazard of insufficient
precision.  Fine.  At four or five decimal places, 
FixedPoint (for instance) produces the results you 
appear to expect.  The problem I am discussing is
entirely an artifact of BINARY floating point.

DECIMAL floating point would be fine... just so the 
math doesn't surprise any reasonably intelligent,
educated user.

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





More information about the Python-list mailing list