From: Lloyd Zusman Date: 2004-05-13T02:30:49+09:00 Subject: Re: Major Addition Bug? "Sean O'Dell" writes: > On Wednesday 12 May 2004 09:53, ts wrote: >> >>>>> "S" == Sean O'Dell writes: >> >> S> raise "false" if ((625.91 + 900.00 + 22.00) != 1547.91) >> >> Well, this is well known > > Well known? I had no idea this bug existed until I wrote a line of > code that double-checked the arithmetic from a different app. I have > code all over doing simple arithmetic like this. Ruby can't add 3 > simple numbers? I don't mean to be disproportionately negative, but > that shakes my faith more than a little. It's just simple arithmetic. > How old is this bug? When is it getting fixed? In 1969 I took a course called Introduction to Computer Programming. In one of the early chapters of the textbook, we learned about a concept called "floating point arithmetic". One aspect of this topic that was drilled into us is the way that floating point arithmetic does not yield exact results. I want to add that this concept, which is so basic to the understanding of programming that it was taught in an introductory course before we even wrote a line of code, was old information even in 1969. This basic concept of floating point arithmetic is every bit as pertinent today as it was in 1969 and the years prior to that. Did you actually not learn this concept before starting to program in Ruby? In the off chance that you were absent that day when they talked about this in school, or that the 5 pages that discussed this in your Introduction to Computer Programming book accidentally got eaten by your dog, I want you to know that the case that you are describing here is _not_ a bug, but rather, an intrisic feature of how computers do certain kinds of arithmetic. Do a search in Google on "floating point arithmetic" (best to put that entire phrase in double quotes) for more information. > Sean O'Dell -- Lloyd Zusman ljz@asfast.com God bless you.