Number Base Converter
Enter a number, choose its base, and get it in binary, octal, decimal and hexadecimal at once.
How the bases work
- Binary (base 2): only 0 and 1. The way computers store numbers.
- Octal (base 8): the digits 0 to 7. Each digit stands for 3 bits.
- Decimal (base 10): the digits 0 to 9, the numbers we use every day.
- Hexadecimal (base 16): the digits 0 to 9 and A to F (A = 10, …, F = 15). Each digit stands for 4 bits. It is used for color codes, memory addresses and more.
The conversion uses BigInt, which handles integers of any size without rounding errors, so even very large integers are converted exactly.
Examples
| Decimal | Binary | Octal | Hexadecimal |
|---|---|---|---|
| 10 | 1010 | 12 | A |
| 255 | 1111 1111 | 377 | FF |
| 256 | 1 0000 0000 | 400 | 100 |
| 500 | 1 1111 0100 | 764 | 1F4 |
| 65,535 | 1111 1111 1111 1111 | 177777 | FFFF |
Input rules
- Whole numbers only. An input that contains a decimal point is an error.
- Allowed characters: 0 and 1 in binary, 0 to 7 in octal, 0 to 9 in decimal, and 0 to 9 and A to F in hexadecimal (uppercase or lowercase). If a character does not fit, the message tells you which character it is.
- Prefixes: the prefix that matches the base you chose (0b for binary, 0o for octal, 0x for hexadecimal) is removed automatically. In hexadecimal, "0b1" is read as the digits 0B1, not as a prefix.
- Separators: spaces and "_" are ignored (for example, 1111 0000 or 1111_0000). In decimal, "," is also ignored.
- Size limit: the number must be below 2 to the power 256 (about 78 decimal digits, 64 hexadecimal digits or 256 binary digits). The input can be up to 1,000 characters.
Negative numbers
A negative number is converted as a minus sign plus its absolute value (-255 is -FF in hexadecimal and -11111111 in binary). Computers often store negative numbers in a different form called "two's complement", but this tool does not support two's complement. -0 becomes 0.
Notes
- Below the result, the number of bits and bytes needed for the absolute value is shown (255 needs 8 bits, or 1 byte).
- Binary and hexadecimal results can be grouped in blocks of 4 digits for readability (copied values have no grouping). Decimal results are grouped with commas every 3 digits.
- To work with the bits of an IP address, you can also use the IPv4 Subnet Calculator.
Frequently asked questions
Do I need to type "0x" for hexadecimal?
No. "0x" only marks a number as hexadecimal, so you can leave it out. If you type it, it is removed automatically.
How large a number can I convert?
Any whole number below 2 to the power 256, which in decimal is a number smaller than about 1.16 × 10 to the power 77.
Can I convert fractions, or get the two's complement of a negative number?
No. This tool converts whole numbers only; fractions and two's complement are not supported.