21-bit Converter + disambiguated reverse
Forward: start at 2 or 3 (bit 0), then ×2 (bit 0) or ×2−1 (bit 1) for the other 20 bits, subtract 1,048,576.
Reverse: parity-invert. When the value is 2 the start is certain (stop). When it is 3 it is ambiguous — could be the
real start or an intermediate 3 that came from 2 — so one disambiguation bit says stop or continue. With that bit the
reverse is always correct.
The disambiguation bit is charged only when the value passes through 3: about a quarter of inputs
need zero, about three quarters need one. The reverse is now correct on every input; the trials show what that
correctness costs on average, on top of the 21 input bits.