Comparison tolerance

From APL Wiki
Revision as of 03:34, 25 February 2024 by Marshall (talk | contribs) (Created page with "'''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 <syntaxhighlight lang=apl inline>⎕CT</syntaxhighlight>. In addition to the comparison functions, tolerance applies to Match and Not Match, Floor, C...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

References