[Jprogramming] dyad ": rounding error

John Randall randall at andromeda.rutgers.edu
Tue Mar 20 20:13:40 HKT 2007


Joey K Tuttle wrote:
> Ah, the perils of floating point numbers....
>
> Even though you say you would never use rational
> numbers in calculations, most accountants do.
> For example, the calculators you mentioned in
> your points often do fixed calculations with
> the number of decimals set as a fixed option.
>
I guess one should note that all floating-point numbers represent
rational numbers, but they do not always obey the laws of rational
arithmetic.  Fixed-point numbers are no different.

> Similarly, many accounting programs store amounts
> of money in cents. e.g. in phone call records, the
> rates (cents/minute) are usually stored as 10000
> times the dollar amount - and so on. Formatting
> the final numbers is only a part of the problem...
>

Excel attempts to make binary floating-point arithmetic look like
decimal by using cosmetic rounding: see

http://www.cs.berkeley.edu/~wkahan/Mindless.pdf#page=3

Best wishes,

John





More information about the Programming mailing list