Floating point exactness & alternatives (summary)

Henry Spencer henry at zoo.toronto.edu
Fri Aug 10 01:43:02 AEST 1990


In article <168 at srchtec.UUCP> johnb at srchtec.UUCP (John Baldwin) writes:
>>Our own experience, in building accounting systems for our own use, is that
>>the problem can often be eliminated by ignoring the decimal point in dollar
>>currencies and thinking of money as measured in pennies.
>
>Doesn't this push him back into the "continued sums" implementation?
>Remember, conversion rates between different currencies "slide" up and down
>at a fairly high frequency...

If you are doing tricky things with exchange rates, all bets are off. :-)
In the simple case, though, if you go to Thomas Cook and buy (say) US$,
they will *not* give you a fraction of a cent even if the mathematical
conversion factor would indicate it.  They will round the amount to an
integer in some way (typically in their favor :-)).  So if you're trying
to keep track of that transaction by program, you don't need to keep the
mathematically-exact amount, which is wrong anyway; it is both sufficient
and correct to use the appropriate rounding function to give an integer,
and store that.
-- 
It is not possible to both understand  | Henry Spencer at U of Toronto Zoology
and appreciate Intel CPUs. -D.Wolfskill|  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list