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

Chris Gonnerman chris.gonnerman at newcenturycomputers.net
Tue Oct 1 21:21:09 EDT 2002


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

> I haven't yet seen a complete definition of "right", so I 
> have no way to prove or disprove that the rounding function 
> above always gives the "right" answer.

How complete do you need?  All arithmetic rounding,
whenever it is performed, must produce results entirely
and exactly equal to the results achieved when doing
the same arithmetic *in decimal*, by hand, on paper,
following one of the standard rounding rules.  There
are two such rules used in the US, "classic" and
"banker's."  For most business purposes, "classic"
rounding ( >= 0.5 up, < 0.5 down) is the expected mode,
but in an ideal world either should be available.

In other words, 0.7 * 0.05 should always be 0.035, and 
never 0.034999...

It's really simple.  For monetary purposes, anyone with
a (successful) eighth-grade education or equivalent
should be able to do the math on paper (or do they even
teach that anymore?) and not be surprised by the
computer's results.

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?

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





More information about the Python-list mailing list