Number bases
Type the number in the base you are starting from, and it appears in all the common bases at once.
The same number in other bases
- Binary11111111
- Octal377
- Decimal255
- Hexadecimalff
- Custom base 3673
How it works
A number base says how many digits are used before moving to the next position. We normally count in base 10 with the digits 0 to 9, while computers work in base 2 with only 0 and 1.
Hexadecimal, base 16, exists to shorten binary. Four binary digits correspond to exactly one hexadecimal digit, which is why a byte always fits in two characters, such as ff for 255.
Digits above nine are written as letters: a means 10, b means 11 and so on up to z, which means 35 in base 36.
This tool works with integers of any size, so even long hexadecimal values keep every digit.
How the tool calculates
The number is read one digit at a time from the left: the value so far is multiplied by the base and the next digit is added. 7ea in base 16 becomes 7, then 7 × 16 + 14 = 126, and finally 126 × 16 + 10 = 2,026. In the other direction the number is written by the browser’s built-in conversion, which uses the characters 0–9 and a–z, never writes leading zeros and puts a minus sign before negative numbers.
2,026 is 11111101010 in binary, 3752 in octal and 1ka in base 36. Base 36 is the highest because ten digits and twenty-six letters make 36 characters. Besides the four usual bases the list shows a custom base, 36 to begin with, and the button on each row copies the number in that base.
What the field accepts
Capital and small letters mean the same, and spaces and underscores between digits are removed, so 1111_0000 in base 2 is 240. Prefixes such as 0x and 0b are not understood. In base 16, 0x1f is rejected, but in base 36 x is a digit, and the same text is then read as the number 42,819. Leading zeros disappear, so 00ff is written ff.
Only whole numbers can be converted, so a decimal point gives an error message. Negative numbers keep their minus sign: −ff is −255 and −11111111 in binary. The tool therefore does not show how a computer stores a negative number in a fixed number of bits.
Background
RFC 4648 calls base 16 the standard hex encoding and says it is case-insensitive. The standard’s alphabet uses the capitals A–F, while JavaScript writes small letters. Both mean the same number.
Ordinary numbers in the browser hold every integer exactly only up to 2⁵³ − 1 = 9,007,199,254,740,991. The tool therefore uses the BigInt integer type, which has no such limit. 2⁶⁴ = 18,446,744,073,709,551,616 then comes out exactly as 10000000000000000 in hexadecimal, a one followed by sixteen zeros.