- Home
- Generators & Encoders
- Number Base Converter
Number Base Converter
Convert numbers between binary, octal, decimal and hexadecimal. Large integers are exact.
What it is for?What it is for?
Computers store numbers in binary, but people write them in decimal, hex or octal depending on the job. Hex shows up in colours, memory addresses and byte dumps, octal in Unix file permissions, binary in bit flags. Type a number once and see it in all four bases.
How to use it
Leave Written in on Detect from prefix and write 0x for hex, 0b for binary or 0o for octal; a number without a prefix is read as decimal. Or choose the base yourself. Hex digits may be upper or lower case. The results have no prefix and hex is shown in lower case.
Exact at any size
The conversion uses BigInt, so a 64-bit ID or a long hash stays exact instead of being rounded. Spaces and underscores used as digit separators are ignored, and a minus sign is kept.
A normal JavaScript number is exact only up to 9007199254740991. 0xffffffffffffffff is 18446744073709551615 here, with every digit right.
Good to know
- Only whole numbers are converted. A decimal point or a fraction is an error.
- Negative numbers keep their sign: -255 is -ff. This is not the two's complement form a CPU uses, so -1 does not become ffffffff.
- A leading 0 alone does not mean octal here. 0755 is read as decimal unless you choose Octal or write 0o755.
It stays in the browser
The conversion runs in this tab. Nothing is sent to a server.