Comparison tolerance
Tolerant comparison is an inexact form of comparison used to mitigate the impact of floating-point rounding error on programs. It considers two numbers equal when their relative difference is smaller than a parameter called the comparison tolerance, and accessed with the system variable ⎕CT
. In addition to the comparison functions, tolerance applies to Match and Not Match, Floor, Ceiling, and Modulus, and search functions defined in terms of Match (not Interval Index).
In an early talk Ken was explaining the advantages of tolerant comparison. A member of the audience asked incredulously, "Surely you don't mean that when A=B and B=C, A may not equal C?" Without skipping a beat, Ken replied, "Any carpenter knows that!" and went on to the next question.
—Paul Berry[1]
The formula now used for comparison tolerance was introduced in SHARP APL by Robert Bernecky and others,[2] following a proposal by Dick Lathwell.[3]
The application of comparison tolerance to search functions presents problems for standard hash-based search methods.[4][5]
External links
- Tolerated Comparison part 1 and part 2 by Marshall Lochbaum
References
- ↑ Roger Hui. Ken Iverson Quotations and Anecdotes. 2005-09-30.
- ↑ Robert Bernecky. "Comparison Tolerance". SATN-23. 1977-06-10.
- ↑ Dick Lathwell. APL comparison tolerance at APL76 (also reproduced in SATN-23).
- ↑ Roger Hui. "Hashing for Tolerant Index-Of" at Dyalog '10.
- ↑ Roger Hui. "Tolerant Unique" (materials (1.5 MB), video (27 mins)) at Dyalog '17.