FileGizmo glossary
Number base
A number base is how many digits a system has before it carries. Decimal has ten, binary two, hexadecimal sixteen. The same quantity looks different in each, and converting between them changes the spelling of a number without changing its value.
A base is the number of distinct digits available before the count carries into the next column. Decimal has ten, so after 9 comes 10. Binary has two, so after 1 comes 10, which is the same quantity as decimal 2 written with fewer symbols.
Changing base changes the spelling and nothing else. 255, ff and 11111111 are three ways to write one quantity.
Why particular bases turn up
Base 2 is what the hardware does. Everything else is a way of writing it that people can read.
Base 16 exists because sixteen is a power of two: exactly two hex digits describe one byte, with nothing left over. That alignment is the whole reason it is used for colours, memory addresses and hashes, where the underlying thing is bytes and a decimal spelling would hide the boundaries.
Base 8 survives mostly in file permissions, where three bits form one digit and 755 is three groups of three flags.
Base 36 is the last base that can be written with the ten digits and the twenty-six letters. That makes it the most compact spelling available using characters that survive being copied, pasted, typed and put in a URL, which is why it appears in short identifiers.
Where conversion goes wrong
A conversion should change the spelling and not the value, and the common implementation stops honouring that at around sixteen digits.
The reason is that the intermediate value is usually a double, which cannot hold an integer past 2^53 exactly. A 64-bit identifier converted through one comes back with different digits and no warning, because the result is still a plausible-looking number. That range is exactly where identifiers live, so it is exactly the case where the conversion matters.
Doing it with arbitrary-precision integers avoids the problem entirely, and costs nothing at the sizes where the naive version was already correct.
Frequently asked questions
Why is hexadecimal used for bytes?
Because sixteen is two to the fourth, so exactly two hex digits describe one byte with no remainder. Decimal has no such alignment, which is why a byte in decimal runs from 0 to 255 and in hex from 00 to ff.
Why does base 36 exist?
It is the largest base writable with the ten digits and the twenty-six letters. That makes it the densest way to write a number using only characters that survive a copy and paste, which is why short identifiers and URL slugs use it.
Does converting a number change it?
No, only its spelling. The quantity is the same. Anything that changes the value during a conversion is a bug, and it is a common one for numbers past sixteen digits.