How to convert decimal to binary
Divide the number by 2 repeatedly and write down each remainder. Reading the remainders from bottom to top gives the binary digits.
Worked example: convert decimal 2026 to binary.
| Division | Quotient | Remainder |
|---|---|---|
| 2026 ÷ 2 | 1013 | 0 |
| 1013 ÷ 2 | 506 | 1 |
| 506 ÷ 2 | 253 | 0 |
| 253 ÷ 2 | 126 | 1 |
| 126 ÷ 2 | 63 | 0 |
| 63 ÷ 2 | 31 | 1 |
| 31 ÷ 2 | 15 | 1 |
| 15 ÷ 2 | 7 | 1 |
| 7 ÷ 2 | 3 | 1 |
| 3 ÷ 2 | 1 | 1 |
| 1 ÷ 2 | 0 | 1 |
Reading the remainders from the bottom up gives 11111101010.
Type any decimal number in the converter above and open Show the working to see these steps for your own value.
Powers of two
Each binary digit is worth a power of two. Knowing these makes binary conversions quick to check:
| Power | Value | Power | Value |
|---|---|---|---|
| 20 | 1 | 28 | 256 |
| 21 | 2 | 29 | 512 |
| 22 | 4 | 210 | 1,024 |
| 23 | 8 | 211 | 2,048 |
| 24 | 16 | 212 | 4,096 |
| 25 | 32 | 213 | 8,192 |
| 26 | 64 | 214 | 16,384 |
| 27 | 128 | 215 | 32,768 |
| 28 | 256 | 216 | 65,536 |
Convert decimal to binary in Excel and code
| Where | Formula | Result |
|---|---|---|
| Excel / Google Sheets | =BASE(2026, 2) | 11111101010 |
| Python | format(2026, "b") | 11111101010 |
| JavaScript | (2026).toString(2) | 11111101010 |
Quick reference
| Decimal | Binary | Octal | Hexadecimal |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 |
| 2 | 10 | 2 | 2 |
| 7 | 111 | 7 | 7 |
| 8 | 1000 | 10 | 8 |
| 10 | 1010 | 12 | A |
| 15 | 1111 | 17 | F |
| 16 | 10000 | 20 | 10 |
| 31 | 11111 | 37 | 1F |
| 64 | 1000000 | 100 | 40 |
| 100 | 1100100 | 144 | 64 |
| 255 | 11111111 | 377 | FF |
| 256 | 100000000 | 400 | 100 |
| 1000 | 1111101000 | 1750 | 3E8 |
| 1024 | 10000000000 | 2000 | 400 |
Negative numbers and two's complement
On paper, a negative number just gets a minus sign: −45 is −101101 in binary. Computers store whole numbers in a fixed
number of bits using two's complement: invert every bit of the positive value and add 1. In 8 bits,
45 is 00101101, so −45 is 11010011 (hex D3). Enter a negative whole number above
to see its 8, 16, 32 and 64-bit forms.
Where you'll see these number systems
- Binary: how computers store everything; bit masks, flags and network subnet masks.
- Octal: Unix and Linux file permissions such as
chmod 755. - Decimal: everyday counting, and how most programs display numbers.
- Hexadecimal: colour codes (
#FF5733), memory addresses, MAC addresses, Unicode code points and hashes. One hex digit is exactly 4 bits, so two digits make a byte.