Unary Number System

Welcome to a number system with just one symbol. We can represent both positive and negative rationals with this number system

1

Base-10 to Unary

Try Presets:
a Rational → ℕ×ℕ Mapping
b Cantor Pairing ℕ×ℕ → ℕ
Unary Representation: 7 ones (z = 7)
Displaying full unary representation.
2

Unary to Base-10 Converter

Length: 7 ones
Unary Count (z) 7
Recovered Fraction
Decimal Value 0.5
a Extracting (k₁, k₂) from z
b Recovering Numerator & Denominator
3

Cantor Pairing Visualizer: 2D Grid to 1D Line

Interactive Walk

Any rational number can be uniquely represented in canonical irreducible form with coprime integers and (where , We first construct a bijective coordinate transformation .

1. Coordinate (Numerator Mapping ):

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:

2. Coordinate (Denominator Mapping ):

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:

3. Diagonal Traversal & Cantor Index :

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:

Grid Size:
Hover or click on any cell in the grid or the 1D tape to inspect its Cantor parameters and unary representation!
Ready
Unfolded 1D Line Tape (The Flattened Line) Scroll horizontally →