How to use the Number Base Converter
- Type a number into the field for the base you already have, for example 255 in the decimal field.
- The binary, octal and hex fields update as you type.
- For other bases such as base 3 or base 36, pick one under Choose another base.
- Use the copy buttons to copy a result. Binary is shown in groups of four digits so the bits are easy to count.
How to convert decimal to binary
Keep dividing the decimal number by 2, then read the remainders from bottom to top. That gives you the binary number. Here's 13 as an example:
| Division | Quotient | Remainder |
|---|---|---|
| 13 ÷ 2 | 6 | 1 |
| 6 ÷ 2 | 3 | 0 |
| 3 ÷ 2 | 1 | 1 |
| 1 ÷ 2 | 0 | 1 |
Read the remainders in reverse and you get 1101. Octal and hex work the same way: just divide by 8 or 16 instead.
How to convert binary to decimal
Start at the rightmost digit. Multiply each digit by its place value, which goes 1, 2, 4, 8, 16 and so on (the powers of 2), then add up the results.
1101₂ = 1×8 + 1×4 + 0×2 + 1×1 = 13
In hexadecimal the place values are 1, 16, 256, 4096 and so on, and the letters A to F stand for 10 to 15. For example, FF₁₆ = 15×16 + 15 = 255 and 1A₁₆ = 1×16 + 10 = 26.
Why four binary digits make one hex digit
Because 16 = 2⁴, every group of four binary digits matches exactly one hex digit. Split a binary number into groups of four starting from the right and you can read off the hex value directly. Octal works the same way with groups of three binary digits.
| Binary | Hex | Binary | Hex |
|---|---|---|---|
| 0000 | 0 | 1000 | 8 |
| 0011 | 3 | 1010 | A |
| 0101 | 5 | 1100 | C |
| 0111 | 7 | 1111 | F |
Example: 1011 0110₂ = B6₁₆ = 182. A color code like #FF8800 is just three pairs of hex digits (255, 136, 0). You can see it as RGB in the color code converter.
Where are number bases used?
- Binary: all data inside a computer, bitwise operations and permission flags
- Octal: Unix and Linux file permissions (for example, chmod 755 = rwxr-xr-x)
- Hexadecimal: memory addresses, web color codes, Unicode code points (U+00E9 = 'é'), MAC addresses
- Base 36: short IDs and URL shortener codes, since it uses all of 0–9 and A–Z
Negative numbers in binary: two's complement
Computers usually store negative numbers in two's complement. To get the negative of a number, take its binary form, flip every bit (0↔1) and add 1. In 8 bits, 5 is 0000 0101 and −5 is 1111 1011. −1 has every bit set: 1111 1111 (hex FF).
This converter shows negative numbers mathematically, with a minus sign in front. If you need the two's complement for a specific bit width, work it out yourself using the method above.