Welcome to a number system with just one symbol. We can represent both positive and negative rationals with this number system
Any rational number can be uniquely represented in canonical irreducible form with coprime integers and (where , We first construct a bijective coordinate transformation → .
The numerator may be positive, zero, or negative (). To fold all integers onto non-negative indices without sign collisions, we interleave positive integers onto even values and negative integers onto odd values:
The denominator is strictly positive (). Because division by zero is undefined, the value corresponds to index 0 on the grid. We map directly to a non-negative coordinate by subtracting 1:
Having mapped any rational number to the lattice point , where and , we determine its position along the anti-diagonal sum :
In the 2D Cartesian grid, all pairs with equal sum lie on the -th anti-diagonal. The number of points strictly preceding diagonal is the triangular number :
Traversing down the diagonal adds an offset of steps, producing the canonical Cantor pairing index . Finally, in the unary number system, is encoded as a tally sequence of exactly ones (with representing the empty tally ε):
See how the 2D grid of pairs (k₁, k₂) folds
into a single 1D line index z. The default
2 × 2 grid shows the fundamental
walk. You can expand up to 5 × 5,
click any cell, or press: