Here's a challenge for floating point lovers.
Rahul Dhesi
dhesi%cirrusl at oliveb.ATC.olivetti.com
Fri Feb 22 09:23:42 AEST 1991
In <265 at nazgul.UUCP> bright at nazgul.UUCP (Walter Bright) writes:
>Think about a bank calculating interest on all its 5.25% checking
>accounts. A penny here, a penny there, after many thousands of transactions
>this adds up to real money. There has been more than one bank fraud where
>a programmer stole money by having partial pennies credited to his personal
>account...
There are two issues here. One is the type of rounding, i.e., whether
it's always up, always down, 5/4 rounding, or even/odd rounding. (The
last is best if you want to avoid a net bias.)
The other issue is that of precision.
You can use even/odd rounding without necessarily doing all
calculations in base 10.
--
Rahul Dhesi <dhesi%cirrusl at oliveb.ATC.olivetti.com>
UUCP: oliveb!cirrusl!dhesi
More information about the Comp.lang.c
mailing list