Xref: utzoo comp.lang.pascal:2878 alt.folklore.computers:1000 Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!uunet!ns-mx!pyrite.cs.uiowa.edu From: jones@pyrite.cs.uiowa.edu (Douglas W. Jones,201H MLH,3193350740,3193382879) Newsgroups: comp.lang.pascal,alt.folklore.computers Subject: Re: Problem in Turbo Pascal 4.0 Message-ID: <381@ns-mx.uiowa.edu> Date: 3 Jan 90 19:47:19 GMT References: <129838@sun.Eng.Sun.COM> Sender: news@ns-mx.uiowa.edu Followup-To: comp.lang.pascal Lines: 35 From article <129838@sun.Eng.Sun.COM>, by linden@adapt.Sun.COM (Peter van der Linden): > Kees Huizing - Eindhoven Univ of Techn - The Netherlands, wants to know: >> the equality operator "=" does not (do) on reals what it pretends to do. >> I accept that it cannot detect perfect equality of reals, but what it >> could do is detect equality up to some representation dependent accuracy. > > A very reasonable question Kees! A number of years ago, a gentleman by the > name of Dijkstra, ... had the very same thought ... > > The experiment was soon deemed a failure when it was found that this had > the inadvertent and unwanted side effect that comparison was no longer > transitive. I.e. if A equalled B, and B equalled C, a program could not > conclude that A = C ! It's worse than that! The PLATO system at the U. or Illinois implemented comparison this way. They had good motives: They didn't want to have to explain to non-numerically-literate users why, for example, 0.1*100.0 wasn't equal to 10.0. It avoided such complaints, but it produced awful results when you tried to code many standard numerical algorithms. For example: If the equality test is modified as above, but the > and < tests are unmodified, it is possible that two of A=B, AB may be true at the same time (although only one of AB may be true). This leads to a real mess. If you modify all comparison operators so that only one of AB will be true, comparisons are suddenly misleading. A<=B means (AB), but suddenly, there are values of A and B such that A<=B is reported as true, but in fact, A is slightly greater than B. As a result, there are values of A and B where A<=B is reported to be true, ((A-B)*10)>0 is also reported as true.