THE PARITY the carry-less sum — XOR every bit, and keep only whether the count is odd
Add all the bits of a number but throw the carry away every time — add mod 2 — and you are left with the parity: 1 if the number of set bits is odd, 0 if even. It is the XOR-fold of all the bits, the sum with no carry at all. One extra parity bit appended to a byte catches any single-bit error (a flip changes the parity), which is the oldest error check in computing — on memory, on serial links, on punched tape. Parity is what addition becomes when you refuse the carry entirely: the answer mod 2, and nothing more.
THE TECHNIQUE parity = XOR-fold of all bits = popcount mod 2 (the carry-less sum)
The demo XOR-folds the bits of a few numbers — the carry-less sum, 1 for an odd bit-count: live demo
HISTORY & CREDIT the parity bit · error detection
“A sum keeps its carries.” — drop them all and you get parity: the answer mod 2, which catches any single-bit flip. The oldest error check is addition minus the carry. cited
the fold · XOR all bits — the sum mod 2, carry discarded at every step. error check · one parity bit catches any single-bit flip (odd/even parity) — memory, RS-232, tape. kin · the sum bit of the adder is the parity of its inputs (dart 375) — parity is the adder with the carry removed.
Add every bit, keep no carry, and only the oddness survives — the sum mod 2, catching any single flip. Addition, minus the carry. the parity bit
RECOMMEND FOR I-13 the carry-less sum, on the compiler
On the canonical compiler, parity of 11 (1011, three ones) is 1; of 3 (11, two ones) is 0 — the XOR-fold:
$ i13 run c_parity.i13 # XOR-fold all bits
RUN OK · 493 step(s) · peak stack 6 · call depth 9
p11 = 1 p7 = 1 p3 = 0 -- parity = sum mod 2, the carry thrown away
Recommend as the batch's close: parity is addition with the carry refused entirely — the XOR-fold, the sum mod 2, the oldest error check — and i13 folds the bits to 1 or 0. Not a keeper (the XOR-fold is the self-inverse family, and a parity bit is a recognizer of single-bit error). The right last note for THE CARRY: the batch began by creating the carry (the half adder's AND) and ends by discarding it (parity's XOR) — and everything between was managing the signal in the middle.