Unary and Tally Converter
Turn a number into unary marks and tally gates of five, or count marks back into a number. Also shows the unary code and Elias gamma code that compression algorithms build on.
How to Use
- Choose number to marks or count marks.
- Type a whole number up to 10,000, or paste a string of marks to count.
- Optionally pick the mark to use, such as | or • or ✓.
- Read the count, the tally as gates of five, the unary code and the Elias gamma code.
- The drawing shows the tally, five strokes to a gate.
Worked Example
13 as tally marks. 13 = 5 + 5 + 3, so draw two gates of four strokes crossed by a fifth, then three single strokes. Anyone can read it as “five, ten, thirteen” without counting every stroke.
13 in compression codes. The unary code is thirteen 1s and a 0 (14 bits). The Elias gamma code writes 13 in binary, 1101 (4 bits), with 3 zeros in front: 0001101, only 7 bits, and still self-delimiting.
The common mistake: calling unary “base 1” and expecting digits. In a real base b, digits run from 0 to b − 1, which in base 1 would leave only the digit 0. Unary works differently: every mark is worth 1 and there are no place values at all, so its length grows with the number itself.
Show Work
Formulas
The First Numbers
Before there were digits there were notches. The Lebombo bone, a baboon fibula about 43,000 years old from the mountains between South Africa and Eswatini, has 29 cut marks; the Ishango bone from the Congo has notches in groups that some read as counts. Shepherds, prisoners and scorekeepers have used tallies ever since, and the gate of five, still seen on scorecards, makes them readable at a glance.
Split tally sticks were official records in England: a notched stick was split in two so that lender and borrower each held half. When the Exchequer finally burned its old tally sticks in 1834, the fire got out of control and burned down most of the Palace of Westminster.
About This Calculator
This converter writes a number up to 10,000 as unary marks with a mark of your choice and as tally gates of five, gives the unary code and Elias gamma code used in compression, and counts pasted marks back into a number. The drawing shows the tally for up to 200.
Everything runs in your browser; nothing is sent anywhere.
Related calculators: Roman Numeral Converter, Zeckendorf and Fibonacci Code Converter, and Number Base Converter.
Frequently Asked Questions
What is unary?
The simplest number system: a number n is written as n marks, so 5 is |||||. It is sometimes called base 1, although it is not a true positional system, since every mark is worth the same. It needs no arithmetic to write, which is why it is the oldest way of recording numbers.
How do tally marks work?
Strokes are grouped in fives, usually four upright strokes crossed by a fifth (a “gate”), so a count can be read at a glance by counting gates. 13 is two gates and three more strokes. In China, Japan and Korea the five strokes of the character 正 are used instead.
What is the unary code?
In data compression, the number n is coded as n ones followed by a zero (or the reverse). It is optimal when small numbers are much more common than large ones, and it is the building block of Golomb, Rice and Elias codes.
What is Elias gamma coding?
A universal code for positive integers: write the number in binary, and put one fewer zeros in front than it has bits. 13 is 1101 in binary (4 bits), so its gamma code is 000 1101. The leading zeros tell the decoder how many bits to read, so numbers can be packed into a stream without separators.
How old are tally marks?
Very old: the Lebombo bone from southern Africa, about 43,000 years old, carries 29 notches, and the Ishango bone from Congo, over 20,000 years old, has grouped notches that may record counts. Tally sticks were used for tax records in England until 1826.
How do I use the Unary and Tally Converter?
Just type or paste your value. The answer shows up right away — there is no button to press. Change anything and it updates by itself.
Does it cost anything or need an account?
No. The tool is completely free, there is no account to create, and it keeps working offline after the page first loads.
Is anything I type uploaded?
No. The tool works entirely on your device, so the values you enter never leave your browser.
Common Use Cases
Counting
13 = two gates of five and three strokes.
Compression
The unary code of 4 is 11110; the Elias gamma code of 13 is 0001101.
Teaching
Compare 100 marks with 1100100, 7 binary digits.
Checking a count
Paste a string of ticks to count them exactly.
Last updated: