A Dye Print Meets Exclusive OR
A pair of registration marks can tell me whether the second pass landed where I intended. But when I make two test prints with the same block and different dye applications, I also want to compare the marks themselves: where did one print leave colour that the other missed?
Imagine recording one row of each swatch as eight yes-or-no observations: 1 for colour, 0 for bare cloth. The first row is 00111100; the second is 00100100. Exclusive OR, usually called XOR, gives a 1 wherever the inputs differ and a 0 wherever they agree.
:- initialization(main).
main :-
First = 60, Second = 36,
Difference is xor(First, Second),
format('Difference: ~d~n', [Difference]),
halt.
package main
import "fmt"
func main() {
first, second := 60, 36
difference := first ^ second
fmt.Printf("Difference: %d\n", difference)
}
Both programs print Difference: 24. Written as eight bits, that is 00011000: two positions disagree. Prolog expresses the arithmetic operation inside a relation; Go uses the ^ operator between the values. In either case, XOR compares every corresponding bit in one operation.
This is a tiny version of image differencing. Digital logic made operations such as XOR practical building blocks, and microprocessors brought bitwise instructions into everyday programming during the 1970s. Here, each bit stands in for a spot on the cloth rather than a switch in a circuit.
The comparison has limits. XOR shows disagreement, but it cannot say which swatch has the extra colour, or how dark either mark is. It also depends on the rows being registered: if the cloth shifts between measurements, a clean print can look different simply because its pixels moved. A useful comparison starts with marks aligned and a consistent rule for deciding what counts as colour.