From: Robert Klemme Date: 2007-09-01T06:50:05+09:00 Subject: Re: 0.06 == 0.06 returns false in Ruby? On 31.08.2007 17:30, M. Edward (Ed) Borasky wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Robert Klemme wrote: >> 2007/8/31, Pe�a, Botp : >>> From: Robert Klemme [mailto:shortcutter@googlemail.com] >>> # And who decides about the size of epsilon and which algorithm to >>> # choose? There is no one size fits all answer to that hence leaving >>> # Float#== the way it is (i.e. compare for exact identical values) is >>> # the only viable option. Otherwise you would soon see similar >>> # questions on the list, i.e., "how come it sometimes works and >>> # sometimes it doesn't". And they become more difficult to answer as >>> # the cases are likely less easy to spot / explain. >>> >>> indeed :( >>> >>> maybe i'm not "realistic" but i thought >>> >>> 0.05 + 0.01 == 0.06 => false >>> >>> was "unrealistic" enough for a simple and plain 2 decimal arithmetic. Even people w zero-know on computers would laugh about it (yes, try explaining it to your wife or kids, eg). >> That's probably the exact reason why not your wife or kids write >> software but people who are (hopefully) experts. :-) If you study >> computer sciences you'll typically hit the topic of numeric issues at >> some point. > > Actually, unless you're a (hard) science or engineering major, you > probably won't. Numerical analysis/methods aren't really considered part > of "computer science". Computer science is mostly about *discrete* > mathematics, data structures, programming languages and their > interpreters and compilers, etc. And you probably won't get it in a > "software engineering" program either. Applied mathematics is your best > shot, I think. Of course I can speak only for Germany but I had a mandatory lecture on numerical analysis during my CS studies. IIRC it was even during the lower grade phase (dunno the proper English wording), i.e. within the first two years. But then again, the "Diplom" is probably considered roughly equivalent to a major. Somehow I thought numerical effects were so basic and common that they are mentioned in all other places as well. Thanks for pointing this out. Kind regards robert