From: "John W. Kennedy" Date: 2004-05-13T12:03:53+09:00 Subject: Re: Major Addition Bug? Sean O'Dell wrote: > Sort of makes me wonder if someone somewhere doesn't make a replacement FPU > that does all of its calculations as real decimal values, or at least > automatically corrects rounding errors. First, because it takes more memory (or gives less precision), and is slower. Second, because they're not "errors"; floating point arithmetic is intended for use in scientific computing, and reality does not come in neatly calibrated decimal fractions of meters, kilograms, and seconds; and artificially constraining calculations to decimal quantization actually increases error. Now, /money/ is decimally quantized. That's why IBM mainframes include decimal arithmetic, and why languages intended to be capable of accounting tasks (COBOL, PL/I, Ada '95, RPG, and some others) do decimal arithmetic, either by decimal hardware or by decimally scaled integer arithmetic (counting in pennies). Java and Ruby have classes named BigDecimal for the same reason, though I am uncertain of whether Ruby's BigDecimal actually does what it seems to be advertising. -- John W. Kennedy "Only an idiot fights a war on two fronts. Only the heir to the throne of the kingdom of idiots would fight a war on twelve fronts" -- J. Michael Straczynski. "Babylon 5", "Ceremonies of Light and Dark"