Base converter

Whole numbers between any bases (binary, octal, decimal, hex, base 36, Base64 digits, base 60), with Horner's scheme and repeated division.

How it works

In base $b$, the digits $d_{k-1} \dots d_1 d_0$ stand for $d_{k-1} b^{k-1} + \dots + d_1 b + d_0$, with each digit between $0$ and $b - 1$. Bases up to 36 use the digits $0$ to $9$ and then the letters $A$ to $Z$ (so $F = 15$ in hexadecimal); here base 64 uses the Base64 alphabet $A$ to $Z$, $a$ to $z$, $0$ to $9$, $+$ and $/$, and any other base takes its digits as a list of values, like $1\ 23\ 45$ for 1 hour 23 minutes 45 seconds in base 60.

Reading a number from base $b$ is best done with Horner’s scheme: $((d_{k-1} \cdot b + d_{k-2}) \cdot b + \dots) \cdot b + d_0$, one multiplication and one addition per digit. Writing a value in base $c$ goes the other way: divide by $c$, the remainder is the last digit, and repeat with the quotient until it is $0$.

Negative numbers keep their sign in front. Computers store them differently (two’s complement, where the top bit counts negatively), but that depends on a fixed word size and is a separate encoding. The Base64 used for e-mail attachments reads bytes in groups of three; for whole groups it agrees with these digits, as in $(\text{TWFu})_{64}$, the bytes of “Man”.

Everything is calculated in your browser. Nothing you type leaves your device.