fp equality

Jerry Leichter uunet!lrw.com!leichter
Thu Dec 2 03:52:04 PST 1993


APL has always defined its equality operator by:

	x = y iff |x-y| < fuzz

where "fuzz" was originally a fixed, small value, and was later made settable
(though at least when I used APL - quite some time ago - it could not be set
to 0, and in fact could not be set directly:  For efficiency, it was always
effectively set to that the test could be done by masking off some number of
low-order bits).

For not-very-sophisticated users, this definition generally produces the results
they expect.  (Note that APL doesn't distinguish, at user level, between reals
and integers - it converts automatically.  So it's important that equality
"feel the same" in both domains.)

Mathematically, APL's equality is a bit odd - it isn't even transitive.

Perhaps modern APL's allow one to run with fuzz=0 (well, I suppose one should
change < to <= in the definition :-) ).  But there's certainly many, many years
of experience with numerical computation using this definition with non-zero
fuzz.  Anyone know what the reactions of numerical analysts is?

							-- Jerry



More information about the Numeric-interest mailing list