From: Sean O'Dell Date: 2004-05-13T03:06:49+09:00 Subject: Re: Major Addition Bug? On Wednesday 12 May 2004 10:50, Lloyd Zusman wrote: > "Sean O'Dell" writes: > > > > I had to massage my floating point math in C/C++ a lot many years ago, > > but I always assumed it was a flaw in the MS compiler, and once I got > > in the habit of doing it, I forgot about it. > > You have a basic misunderstanding of floating point math if you consider > its rounding and truncation characteristics to be a compiler bug. This is absolutely true; I've never taken any computer class, so I completely missed that basic information. > As other people have mentioned, there is a BigDecimal class in Ruby > that behaves closer to the way that you want. Now that I know what it is, I'm fine with returning to old behavior and just massaging my comparisons. > Also, consider this: if you always want the computer to give you exact > results, what should these exact results be for each of the following > arithmetic evaluations? ... > > a = 1/3 Well, this has an infinite decimal value even in plain math. Everyone should expect his sort of rounding problem. But the simple arithmetic rounding error is not something you would anticipate without, say, having a professor point your nose right at it. Anyway, thanks for the info everyone, Sean O'Dell