Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!ginosko!uunet!mstan!amull From: amull@Morgan.COM (Andrew P. Mullhaupt) Newsgroups: comp.lang.c Subject: Re: Bug? Summary: Language with comparison tolerance: APL Message-ID: <415@e-street.Morgan.COM> Date: 2 Oct 89 14:19:11 GMT References: <19831@mimsy.UUCP> <15852@dartvax.Dartmouth.EDU> <364@capmkt.COM> <192@bbxsda.UUCP> Organization: Morgan Stanley & Co. NY, NY Lines: 26 > I remember seeing a language several years ago that had *two* equality > operators. One of them was "equal" and the other "approx. equal". > The fuzz factor was settable under program control. It was a long > time ago and I don't remember which language it was. Does anybody > remember any such languages? > APL has the 'fuzz' factor, and it's called Comparison Tolerance. (quad CT for you APL types...) It's not a good idea for floating point arithmetic, as my previous posting made clear, but it is a necessary evil in a language where you don't have different integer and real types. Since you can't tell from syntax if a variable is real or integer, you often implicitly compare reals for equality in indexing arrays. The programmer is able to set the level of the fuzz factor as an environment variable, and this leads to difficulties if this variable is changed by running in more than one environment. (This happens a lot in APL; each workspace may have a totally different environment, yet code is often 'Re-Used' by simply copying it from one to another.) APL offers the sensible option of setting the comparison tolerance to 0, which (in good interpreters) eliminates the extra arithmetic entirely and allows the programmer to develop code which avoids the pitfall of comparing floating point representations for equality. Later, Andrew Mullhaupt