Exact comparison explorer

Handwired's emitCompare returns a bit equal to JavaScript's comparison for every FP32 value in the declared range. Change the inputs, the relation and the grid, then fuzz thousands of random pairs.

Interactive demo

emitCompare(circuit, a, rel, b)

614 >= 614

JS says true

turn the grid off, then nudge a by the smallest FP32 step

Exact match

emitSelect(bit, b, a)614
emitMinimumExact(a, b)614

What exactness costs

with integer grid
any FP32 (sign cascade)

Fuzz it

Why does the grid change the cost?

With both operands declared on an integer grid, a >= b is built from the integer difference as relu(1 − relu(−D)) — 2 operations. Without a grid, the difference is lifted by a sign cascade of power-of-two multiplications and clamps until any nonzero difference down to 2⁻¹⁴⁹ reaches 1 — more operations and layers, the same bits.

What are rounding points?

Operations whose FP32 evaluation carries meaning, which a backend must keep intact: 'integer bit' for the grid form and 'sign cascade' for the general form. circuit.roundingPoints() lists them.

Loading Handwired…