Number Base Converter
Convert binary, octal, decimal, hex and any base 2–36, with two's complement
| Width | As signed | As unsigned | Hex | Binary |
|---|---|---|---|---|
| 8-bit | -1 | 255 | FF | 1111 1111 |
| 16-bit | 255 | 255 | 00 FF | 0000 0000 1111 1111 |
| 32-bit | 255 | 255 | 00 00 00 FF | 0000 0000 0000 0000 0000 0000 1111 1111 |
| 64-bit | 255 | 255 | 00 00 00 00 00 00 00 FF | 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 1111 1111 |
Runs entirely in your browser. Nothing you type or upload is sent to us or stored.
Results are for general guidance. Please check anything important before relying on it. Terms of use
How to Use
- Type a whole number into any box: Decimal, Binary, Octal, Hexadecimal or the Base N box. Prefixes like
0x,0band0oare fine, and so are spaces and underscores. - The other boxes update as you type. If you enter a digit the base doesn't allow (such as 2 in binary), a red message tells you which digits are valid.
- Pick any base from 2 to 36 in Any other base to convert to base 3, base 32, base 36 and so on.
- Switch on Group digits to show binary in groups of 4, hex in pairs and decimal with Indian commas. Use ± Change sign for negative numbers.
- Scroll to the Two's complement table to see the 8, 16, 32 and 64-bit patterns, and the same bits read as signed and unsigned values. Tap Copy next to any box to copy it.
What is a number base?
The base (or radix) is how many different digits a number system uses. This number base converter moves a number between any two bases from 2 to 36. We count in base 10, with digits 0–9. Computers store everything in base 2 (binary, digits 0 and 1). Programmers use base 16 (hexadecimal, 0–9 and A–F) and base 8 (octal, 0–7) as compact ways to write binary, because one hex digit is exactly 4 bits and one octal digit is exactly 3 bits. Bases above 10 borrow letters, so base 36 uses all of 0–9 and A–Z.
In every base, each position is worth the base times the position to its right:
9C (base 16) = 9×16 + 12×1 = 156
234 (base 8) = 2×64 + 3×8 + 4 = 156
Worked example: 156 to binary
Divide by 2 again and again, writing down each remainder, then read the remainders from bottom to top:
78 ÷ 2 = 39 r 0
39 ÷ 2 = 19 r 1
19 ÷ 2 = 9 r 1
9 ÷ 2 = 4 r 1
4 ÷ 2 = 2 r 0
2 ÷ 2 = 1 r 0
1 ÷ 2 = 0 r 1 → 156 = 1001 1100 (binary)
Now group the bits: in fours from the right, 1001 = 9 and 1100 = 12 = C, so the hex value is 9C. In threes, 010 011 100 gives octal 234. Type 156 into the Decimal box and switch on Group digits to see the same result.
Negative numbers and two's complement
Ordinary maths writes a negative number with a minus sign, and so does this converter in every base (−156 is −9C in hex). A computer, though, stores signed integers in a fixed number of bits using two's complement: write the positive value in binary, flip every bit, then add 1.
The same 8 bits FB mean −5 when read as a signed byte and 251 when read as unsigned (251 − 256 = −5). The two's complement table in the tool shows both readings for 8, 16, 32 and 64 bits, or the allowed range if the number does not fit:
| Width | Signed range | Unsigned range | Common names |
|---|---|---|---|
| 8-bit | −128 to 127 | 0 to 255 | byte, int8, uint8 |
| 16-bit | −32,768 to 32,767 | 0 to 65,535 | short, int16 |
| 32-bit | −2,147,483,648 to 2,147,483,647 | 0 to 4,294,967,295 | int, int32 |
| 64-bit | −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 | 0 to 18,446,744,073,709,551,615 | long, int64 |
Where you meet other bases
- Colour codes:
#2F6FEDis three hex bytes: red 2F = 47, green 6F = 111, blue ED = 237. - Linux file permissions:
chmod 755is octal; 7 = 111 = rwx for the owner, 5 = 101 = r-x for group and others. - Networking: the subnet mask 255.255.255.0 is 24 ones followed by 8 zeros in binary, which is why it is written /24.
- Memory addresses, MAC addresses and hashes are written in hex.
- Base 36 is used for short IDs and URL codes because it packs large numbers into few characters (1,295 is just
ZZ).
Very large numbers
Many online converters use JavaScript's normal numbers. Those are exact only up to 2⁵³ (9,007,199,254,740,992), and anything bigger gets rounded without warning. This converter uses BigInt arithmetic, so a 64-bit value, a 128-bit hash or a 1,000-digit number converts exactly.
Tips
- You can paste values with prefixes (
0xFF,0b1010,0o17), spaces, underscores or Indian commas (1,00,000). - Only whole numbers are converted. Fractions such as 10.5 aren't supported.
- Base64 (used for encoding files as text) isn't a number base in this sense. Use the Base64 encoder for that.