THE FOLD / BOSS / THE WALL / THE FLOAT EQUALITY
THE FLOAT EQUALITY
a tolerance moves the uncertainty into a constant nobody revisits
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
There are at least three notions of “the same number” in floating point, and they disagree with each other by design rather than by accident.
LIT verified live.
LIT verified live.
NaN === NaN is false. 0 === -0 is true, but 1/0 === 1/-0 is false and Object.is(0, -0) is false — the same two values, three verdicts. Across 200,000 near-pairs the implication runs one way only: equality forces epsilon-closeness, with 0 counterexamples, while 106,390 pairs are within 1e-9 and are not equal.2 HOW IT WAS WEAVED · AI + HUMAN
The three notions are IEEE 754 equality, bitwise identity, and application tolerance; only the first two are specified anywhere.
AVAN (AI) corrected how the zero was reported. My harness printed “equal but not within epsilon: 0” as though it were a measurement that came out empty. It is not —
AVAN (AI) corrected how the zero was reported. My harness printed “equal but not within epsilon: 0” as though it were a measurement that came out empty. It is not —
a === b forces |a-b| to be exactly zero, so that count can never be anything else. Reported as a count it looks like a near miss; reported as a one-way implication it is the actual structure.3 ONE DIMENSION
Five comparisons, and what each operator says.
4 TWO DIMENSIONS · INTERACTIVE
Move the tolerance and watch the two tests separate.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: one question, three answers.
AVAN’s addition (the inverse-companion): the forward reading is that float equality is unreliable and you should compare with a tolerance. The inverse is that the tolerance is a claim about your problem that the numbers cannot check.
=== is fully specified and always right about what it was asked; 1e-9 is a guess about how much difference matters here, and it will be wrong at some scale in the same program. Read backwards, replacing equality with a tolerance does not remove the uncertainty — it moves it out of the standard and into a constant nobody will revisit.LIT NaN === NaN is false, 0 === -0 is true but 1/0 === 1/-0 is false and Object.is(0,-0) is false - the same two values, three verdicts - and across 200,000 near-pairs the implication runs one way only: equality forces epsilon-closeness with 0 counterexamples, while 106,390 pairs are within 1e-9 and are not equal
FIG The three notions are IEEE 754 equality, bitwise identity, and application tolerance; only the first two are specified anywhere. AVAN corrected how the zero was reported: my harness printed equal-but-not-within-epsilon as 0 as though it were a measurement that came out empty, when a === b forces the difference to be exactly zero, so that count can never be anything else. Reported as a count it looks like a near miss; as a one-way implication it is the actual structure.
FIG The three notions are IEEE 754 equality, bitwise identity, and application tolerance; only the first two are specified anywhere. AVAN corrected how the zero was reported: my harness printed equal-but-not-within-epsilon as 0 as though it were a measurement that came out empty, when a === b forces the difference to be exactly zero, so that count can never be anything else. Reported as a count it looks like a near miss; as a one-way implication it is the actual structure.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE WALL · David Lee Wise (ROOT0), with AVAN