THE FOLD / SPAWN / THE SANDBOX / THE MODULO SIGN
THE MODULO SIGN
one identity, two answers
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
What is minus seven modulo three? Every language answers, none of them hesitates, and they do not all say the same thing.
LIT verified live. over every pair of integers from −10 to 10 with a non-zero divisor — 420 pairs — truncated remainder and floored remainder disagree on 146 of them: 34.8%.
LIT verified live. over every pair of integers from −10 to 10 with a non-zero divisor — 420 pairs — truncated remainder and floored remainder disagree on 146 of them: 34.8%.
−7 % 3 is −1 in C, Java and JavaScript, and 2 in Python and Ruby. Both satisfy the defining identity a = b·q + r; they differ only in which way q was rounded, and the choice is invisible in the expression.2 HOW IT WAS WEAVED · AI + HUMAN
The split follows truncated versus floored division — C99 mandated truncation, Python chose flooring so that the remainder always carries the divisor’s sign, and Knuth argued for the latter.
AVAN (AI) swept the whole grid rather than showing the famous example, because 34.8% says how large the disagreement is. It is not a corner: over a third of all sign combinations differ, and every one of them is a plausible index calculation. The 0 that matters is elsewhere — there are no pairs where both operands are positive and the two disagree, which is exactly why this survives every test written by someone who only tried positive numbers.
AVAN (AI) swept the whole grid rather than showing the famous example, because 34.8% says how large the disagreement is. It is not a corner: over a third of all sign combinations differ, and every one of them is a plausible index calculation. The 0 that matters is elsewhere — there are no pairs where both operands are positive and the two disagree, which is exactly why this survives every test written by someone who only tried positive numbers.
3 ONE DIMENSION
420 pairs. 146 disagreements. Both correct.
4 TWO DIMENSIONS · INTERACTIVE
Move across the grid and watch the sign flip.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object.
AVAN’s addition (the inverse-companion): the forward reading is to know which remainder your language gives. The inverse is that the operator was never fully specified by its name — ‘modulo’ names a relation that two different functions satisfy, and each language picked one and called it the obvious meaning. Read backwards, the identity
a = b·q + r does not determine r until you also say how q rounds, and a symbol that hides half its definition will be read as the half the reader already believed.LIT over every pair of integers from -10 to 10 with a non-zero divisor - 420 pairs - truncated remainder and floored remainder disagree on 146 of them, 34.8%: -7 % 3 is -1 in C, Java and JavaScript and 2 in Python and Ruby, both satisfying the defining identity a = b*q + r and differing only in which way q was rounded, and there are 0 disagreements among pairs where both operands are positive
FIG The split follows truncated versus floored division - C99 mandated truncation, Python chose flooring so the remainder carries the divisor's sign, and Knuth argued for the latter. AVAN swept the whole grid rather than showing the famous example, because 34.8% says how large the disagreement is: over a third of all sign combinations differ, and every one is a plausible index calculation. The 0 among positive pairs is why this survives every test written by someone who only tried positive numbers.
FIG The split follows truncated versus floored division - C99 mandated truncation, Python chose flooring so the remainder carries the divisor's sign, and Knuth argued for the latter. AVAN swept the whole grid rather than showing the famous example, because 34.8% says how large the disagreement is: over a third of all sign combinations differ, and every one is a plausible index calculation. The 0 among positive pairs is why this survives every test written by someone who only tried positive numbers.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of THE SANDBOX · David Lee Wise (ROOT0), with AVAN