From: "M. Edward (Ed) Borasky" Date: 2007-09-01T00:23:17+09:00 Subject: Re: 0.06 == 0.06 returns false in Ruby? -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Bertram Scharpf wrote: > Hi, > > Am Freitag, 31. Aug 2007, 17:03:38 +0900 schrieb Daniel DeLorme: >>> Unfortunately, there is no easy solution to this problem. Here is a >>> catalog of often proposed solutions and why they do not work: >> But it would fix 99% of problems. It would be worth it just for the sake of >> reducing those questions on the list :-P >> >> Seriously though, since floating point calculations are approximative to >> start with, what would be wrong with making them more intuitive >> approximations? IMHO Float should use the above algorithm for == and >> reserve normal floating point arithmetic for eql? > > I alway liked it to be forced to decide what are countable > dimensions and what are continuous ones. This made my > programming style much clearer. > > Bertram > > Well ... since *everything* in computing is countable ... :) But seriously, real computing on real digital machines involves translation from infinite and/or continuous semantics to very large finite discrete processes. About the only thing that's truly infinite is the time it takes to complete while true do end But there are some techniques not terribly well known that improve on floating point arithmetic as normally implemented in hardware. They're too expensive for mass-market hardware, so they're usually implemented in software. Interval arithmetic has already been mentioned, but there are some others. Try "A New Approach to Scientific Computation" by Kulisch and Miranker. Most of these are historical curiosities these days because of the widespread distribution of high-performance open-source libraries for exact and symbolic computation, such as GiNaC, GMP, CLN, etc. And it's pretty easy using SWIG to interface one or more of these to Ruby. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFG2DJg8fKMegVjSM8RAqz5AJ9iT+1hEDwtuYht2pnp/cnup/B2QwCgzIte BwjwjradiTPNAV4h8LX/bj8= =wT6P -----END PGP SIGNATURE-----