Decimal to binary converter
Convert decimal numbers to binary — by repeated division by 2, every step shown. Exact at any size, with a worked example and a table of common values. Free, and computed in your browser.
Part of developer tools.
Binary
10101101
Octal
255
Decimal
173
Hexadecimal
AD
Decimal to binary table
| Decimal | Binary |
|---|---|
| 0 | 0 |
| 1 | 1 |
| 2 | 10 |
| 3 | 11 |
| 4 | 100 |
| 5 | 101 |
| 6 | 110 |
| 7 | 111 |
| 8 | 1000 |
| 9 | 1001 |
| 10 | 1010 |
| 11 | 1011 |
| 12 | 1100 |
| 13 | 1101 |
| 14 | 1110 |
| 15 | 1111 |
| 16 | 10000 |
| 100 | 1100100 |
| 127 | 1111111 |
| 255 | 11111111 |
| 256 | 100000000 |
| 1000 | 1111101000 |
| 1024 | 10000000000 |
| 4096 | 1000000000000 |
| 65535 | 1111111111111111 |
| 4294967295 | 11111111111111111111111111111111 |
| 18446744073709551615 | 1111111111111111111111111111111111111111111111111111111111111111 |
The last rows are the largest 32-bit and 64-bit unsigned values. The second is past the point where ordinary JavaScript numbers start rounding; the table and the converter above both compute with BigInt, so every digit is exact.
How to convert decimal to binary
Divide the decimal number by 2, write down the remainder, and repeat with the quotient until it reaches 0. The remainders, read from the last one back to the first, are the binary digits. For 173: 173 ÷ 2 = 86 remainder 1; 86 ÷ 2 = 43 remainder 0; 43 ÷ 2 = 21 remainder 1; 21 ÷ 2 = 10 remainder 1; 10 ÷ 2 = 5 remainder 0; 5 ÷ 2 = 2 remainder 1; 2 ÷ 2 = 1 remainder 0; 1 ÷ 2 = 0 remainder 1. Read upwards, that is 10101101. For small numbers it is often quicker to take away the largest power of two that fits, again and again, and write a 1 for each power used: 173 = 128 + 32 + 8 + 4 + 1.
Decimal and binary side by side
The largest 16-bit value is 65535 in decimal and 1111111111111111 in binary: 5 digits against 16. A decimal digit is worth log₂ 10 ≈ 3.32 bits — not a whole ratio, so decimal and binary digits never line up and there is no digit-by-digit shortcut: the whole number has to be divided down, as above. Binary is what bit masks, flags and subnet masks are reasoned in: a /24 network mask is twenty-four 1 bits followed by eight 0 bits, 255.255.255.0 once written in decimal. In JavaScript and Python source, 173 is written 173 with no prefix in decimal and 0b10101101 in binary. Paste a prefixed number into the converter and it switches to the matching base; a number with no prefix is read in the selected base — decimal on this page.
Other conversions
Going the other way? Binary to decimal converter.
Or open the full number base converter and see a number in all four bases at once.