From: Calamitas Date: 2007-09-02T20:47:45+09:00 Subject: Re: Bug in % (Float)? On 02/09/07, Calamitas wrote: > You can change Ruby's POV, sure. It depends on what you want. The best > result for every atomic operation, or the best result overall. The > latter sounds ideal, but I don't believe it can be done in general. > (If you can do that, I'm pretty sure you'll be famous.) The former is > something that can be done and that I believe modern processors' > floating point units do or try to do. It does req This is the first time Gmail does this on me. Anyway, what I wanted to say is that it does require the programmer to think about error propagation, and that's not easy, but unless you can obtain the ideal of the best overall result, the programmer still needs to think about error propagation, which may be harder because the more magic that happens the more unpredictable things become. Also, it will be tempting to not think about error propagation and the software could run correctly for a long while, pass all tests, but then break in the most unexpected and horrible way. Compare this to the 0.06 == 0.06 thread. 0.05 + 0.01 == 0.06 is false according to Ruby. Both arguments to == have errors on them. == too is a discontinuous function (although an unusual one), and you get results that are way off from what you want. Of course, == could be changed to use an epsilon comparison, but that just postpones the problem. Same thing with % and other floating point operations. Regards, Peter