Bug?

Andrew P. Mullhaupt amull at Morgan.COM
Tue Oct 3 00:19:11 AEST 1989


> 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 



More information about the Comp.lang.c mailing list