Free tool
Decimal to binary converter
To convert decimal to binary, divide by 2 again and again and read the remainders from the bottom up: 13 → 1101. Type any whole number, negative number or fraction below and get the binary result with every division step.
Free · no sign-up · runs in your browser, nothing is uploaded
1001 1100
8 bits
Binary (2)
1001 1100
Octal (8)
234
Decimal (10)
156
Hex (16)
9C
- 8-bit pattern
- 1001 1100
- hex
- 0x9C
- as unsigned
- 156
- as signed
- -100
The top bit is set, so a signed 8-bit type reads these bits as -100.
Click a bit to flip it. The numbers under each byte are bit positions (0 is the lowest bit).
Divide the whole part (156) by 2 again and again until the quotient is 0. The remainders, read from the bottom up, are the binary digits.
| divide | quotient | remainder |
|---|---|---|
| 156 ÷ 2 | 78 | 0 |
| 78 ÷ 2 | 39 | 0 |
| 39 ÷ 2 | 19 | 1 |
| 19 ÷ 2 | 9 | 1 |
| 9 ÷ 2 | 4 | 1 |
| 4 ÷ 2 | 2 | 0 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Bottom up: 10011100
Result: 10011100 (binary)
The divide-by-2 method
Divide the number by 2, write down the remainder (0 or 1), and divide the quotient again. Stop when the quotient is 0. The binary number is the remainders read bottom up.
| Division | Quotient | Remainder |
|---|---|---|
| 156 ÷ 2 | 78 | 0 |
| 78 ÷ 2 | 39 | 0 |
| 39 ÷ 2 | 19 | 1 |
| 19 ÷ 2 | 9 | 1 |
| 9 ÷ 2 | 4 | 1 |
| 4 ÷ 2 | 2 | 0 |
| 2 ÷ 2 | 1 | 0 |
| 1 ÷ 2 | 0 | 1 |
Bottom up: 10011100. The first remainder is the last bit, because it says whether the number is even. The same method works for any base: divide by 16 for hex, by 8 for octal.
The subtraction method
Find the largest power of two that fits, subtract it, and repeat with what is left. Each power you used is a 1 bit.
156 - 128 = 28 → 128s place: 1
28 - 64 → 64s place: 0 (too big)
28 - 32 → 32s place: 0 (too big)
28 - 16 = 12 → 16s place: 1
12 - 8 = 4 → 8s place: 1
4 - 4 = 0 → 4s place: 1
2s place: 0, 1s place: 0
156 = 1001 1100Padding to 8, 16, 32 or 64 bits
A binary number has no leading zeros, but stored values have a fixed width. 156 is 10011100 as a byte, 00000000 10011100 as a 16-bit value. Pick the width in the converter and it pads, and warns you if the number does not fit.
| Width | Unsigned range | Signed range |
|---|---|---|
| 8-bit | 0 to 255 | -128 to 127 |
| 16-bit | 0 to 65,535 | -32,768 to 32,767 |
| 32-bit | 0 to 4,294,967,295 | -2,147,483,648 to 2,147,483,647 |
| 64-bit | 0 to 18,446,744,073,709,551,615 | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
Negative decimal numbers in binary
Fixed-width signed integers use two’s complement. To write -x in N bits:
-20 in 8 bits 20 = 0001 0100 invert = 1110 1011 add 1 = 1110 1100 ← -20
Check: as unsigned, 1110 1100 is 236, and 236 - 256 = -20. Python’s bin(-20) prints -0b10100 with a minus sign instead, because Python integers have no fixed width; mask it to get the bits: format(-20 & 0xFF, '08b').
Decimal fractions: multiply by 2
For the part after the point, multiply by 2. The whole part of each result (0 or 1) is the next bit; keep the fraction and repeat.
0.625 × 2 = 1.25 → 1 0.25 × 2 = 0.5 → 0 0.5 × 2 = 1.0 → 1 0.625 = 0.101 0.1 × 2 = 0.2 → 0 0.2 × 2 = 0.4 → 0 0.4 × 2 = 0.8 → 0 0.8 × 2 = 1.6 → 1 0.6 × 2 = 1.2 → 1 0.2 × 2 = 0.4 → 0 ← 0.2 again: it repeats 0.1 = 0.0(0011)
The converter finds where a fraction starts repeating and shows the repeating digits in brackets, so you get the exact answer instead of a rounded one.
Decimal to binary in code
// JavaScript
(156).toString(2) // '10011100'
(10).toString(2).padStart(8, '0') // '00001010'
BigInt.asUintN(8, -20n).toString(2) // '11101100' (two's complement)
# Python
bin(156) # '0b10011100'
format(10, '08b') # '00001010'
f'{156:b}' # '10011100'
// Go
strconv.FormatInt(156, 2) // "10011100"
fmt.Sprintf("%08b", 10) // "00001010"
# Bash
echo "obase=2; 156" | bc # 10011100The reverse is on the binary to decimal page, and the binary converter handles hex, octal and any base up to 36.
Decimal to binary table, 0 to 255
Every byte value in decimal, 8-bit binary and hex.
| dec | binary | hex |
|---|---|---|
| 0 | 00000000 | 00 |
| 1 | 00000001 | 01 |
| 2 | 00000010 | 02 |
| 3 | 00000011 | 03 |
| 4 | 00000100 | 04 |
| 5 | 00000101 | 05 |
| 6 | 00000110 | 06 |
| 7 | 00000111 | 07 |
| 8 | 00001000 | 08 |
| 9 | 00001001 | 09 |
| 10 | 00001010 | 0A |
| 11 | 00001011 | 0B |
| 12 | 00001100 | 0C |
| 13 | 00001101 | 0D |
| 14 | 00001110 | 0E |
| 15 | 00001111 | 0F |
| 16 | 00010000 | 10 |
| 17 | 00010001 | 11 |
| 18 | 00010010 | 12 |
| 19 | 00010011 | 13 |
| 20 | 00010100 | 14 |
| 21 | 00010101 | 15 |
| 22 | 00010110 | 16 |
| 23 | 00010111 | 17 |
| 24 | 00011000 | 18 |
| 25 | 00011001 | 19 |
| 26 | 00011010 | 1A |
| 27 | 00011011 | 1B |
| 28 | 00011100 | 1C |
| 29 | 00011101 | 1D |
| 30 | 00011110 | 1E |
| 31 | 00011111 | 1F |
| 32 | 00100000 | 20 |
| 33 | 00100001 | 21 |
| 34 | 00100010 | 22 |
| 35 | 00100011 | 23 |
| 36 | 00100100 | 24 |
| 37 | 00100101 | 25 |
| 38 | 00100110 | 26 |
| 39 | 00100111 | 27 |
| 40 | 00101000 | 28 |
| 41 | 00101001 | 29 |
| 42 | 00101010 | 2A |
| 43 | 00101011 | 2B |
| 44 | 00101100 | 2C |
| 45 | 00101101 | 2D |
| 46 | 00101110 | 2E |
| 47 | 00101111 | 2F |
| 48 | 00110000 | 30 |
| 49 | 00110001 | 31 |
| 50 | 00110010 | 32 |
| 51 | 00110011 | 33 |
| 52 | 00110100 | 34 |
| 53 | 00110101 | 35 |
| 54 | 00110110 | 36 |
| 55 | 00110111 | 37 |
| 56 | 00111000 | 38 |
| 57 | 00111001 | 39 |
| 58 | 00111010 | 3A |
| 59 | 00111011 | 3B |
| 60 | 00111100 | 3C |
| 61 | 00111101 | 3D |
| 62 | 00111110 | 3E |
| 63 | 00111111 | 3F |
| dec | binary | hex |
|---|---|---|
| 64 | 01000000 | 40 |
| 65 | 01000001 | 41 |
| 66 | 01000010 | 42 |
| 67 | 01000011 | 43 |
| 68 | 01000100 | 44 |
| 69 | 01000101 | 45 |
| 70 | 01000110 | 46 |
| 71 | 01000111 | 47 |
| 72 | 01001000 | 48 |
| 73 | 01001001 | 49 |
| 74 | 01001010 | 4A |
| 75 | 01001011 | 4B |
| 76 | 01001100 | 4C |
| 77 | 01001101 | 4D |
| 78 | 01001110 | 4E |
| 79 | 01001111 | 4F |
| 80 | 01010000 | 50 |
| 81 | 01010001 | 51 |
| 82 | 01010010 | 52 |
| 83 | 01010011 | 53 |
| 84 | 01010100 | 54 |
| 85 | 01010101 | 55 |
| 86 | 01010110 | 56 |
| 87 | 01010111 | 57 |
| 88 | 01011000 | 58 |
| 89 | 01011001 | 59 |
| 90 | 01011010 | 5A |
| 91 | 01011011 | 5B |
| 92 | 01011100 | 5C |
| 93 | 01011101 | 5D |
| 94 | 01011110 | 5E |
| 95 | 01011111 | 5F |
| 96 | 01100000 | 60 |
| 97 | 01100001 | 61 |
| 98 | 01100010 | 62 |
| 99 | 01100011 | 63 |
| 100 | 01100100 | 64 |
| 101 | 01100101 | 65 |
| 102 | 01100110 | 66 |
| 103 | 01100111 | 67 |
| 104 | 01101000 | 68 |
| 105 | 01101001 | 69 |
| 106 | 01101010 | 6A |
| 107 | 01101011 | 6B |
| 108 | 01101100 | 6C |
| 109 | 01101101 | 6D |
| 110 | 01101110 | 6E |
| 111 | 01101111 | 6F |
| 112 | 01110000 | 70 |
| 113 | 01110001 | 71 |
| 114 | 01110010 | 72 |
| 115 | 01110011 | 73 |
| 116 | 01110100 | 74 |
| 117 | 01110101 | 75 |
| 118 | 01110110 | 76 |
| 119 | 01110111 | 77 |
| 120 | 01111000 | 78 |
| 121 | 01111001 | 79 |
| 122 | 01111010 | 7A |
| 123 | 01111011 | 7B |
| 124 | 01111100 | 7C |
| 125 | 01111101 | 7D |
| 126 | 01111110 | 7E |
| 127 | 01111111 | 7F |
| dec | binary | hex |
|---|---|---|
| 128 | 10000000 | 80 |
| 129 | 10000001 | 81 |
| 130 | 10000010 | 82 |
| 131 | 10000011 | 83 |
| 132 | 10000100 | 84 |
| 133 | 10000101 | 85 |
| 134 | 10000110 | 86 |
| 135 | 10000111 | 87 |
| 136 | 10001000 | 88 |
| 137 | 10001001 | 89 |
| 138 | 10001010 | 8A |
| 139 | 10001011 | 8B |
| 140 | 10001100 | 8C |
| 141 | 10001101 | 8D |
| 142 | 10001110 | 8E |
| 143 | 10001111 | 8F |
| 144 | 10010000 | 90 |
| 145 | 10010001 | 91 |
| 146 | 10010010 | 92 |
| 147 | 10010011 | 93 |
| 148 | 10010100 | 94 |
| 149 | 10010101 | 95 |
| 150 | 10010110 | 96 |
| 151 | 10010111 | 97 |
| 152 | 10011000 | 98 |
| 153 | 10011001 | 99 |
| 154 | 10011010 | 9A |
| 155 | 10011011 | 9B |
| 156 | 10011100 | 9C |
| 157 | 10011101 | 9D |
| 158 | 10011110 | 9E |
| 159 | 10011111 | 9F |
| 160 | 10100000 | A0 |
| 161 | 10100001 | A1 |
| 162 | 10100010 | A2 |
| 163 | 10100011 | A3 |
| 164 | 10100100 | A4 |
| 165 | 10100101 | A5 |
| 166 | 10100110 | A6 |
| 167 | 10100111 | A7 |
| 168 | 10101000 | A8 |
| 169 | 10101001 | A9 |
| 170 | 10101010 | AA |
| 171 | 10101011 | AB |
| 172 | 10101100 | AC |
| 173 | 10101101 | AD |
| 174 | 10101110 | AE |
| 175 | 10101111 | AF |
| 176 | 10110000 | B0 |
| 177 | 10110001 | B1 |
| 178 | 10110010 | B2 |
| 179 | 10110011 | B3 |
| 180 | 10110100 | B4 |
| 181 | 10110101 | B5 |
| 182 | 10110110 | B6 |
| 183 | 10110111 | B7 |
| 184 | 10111000 | B8 |
| 185 | 10111001 | B9 |
| 186 | 10111010 | BA |
| 187 | 10111011 | BB |
| 188 | 10111100 | BC |
| 189 | 10111101 | BD |
| 190 | 10111110 | BE |
| 191 | 10111111 | BF |
| dec | binary | hex |
|---|---|---|
| 192 | 11000000 | C0 |
| 193 | 11000001 | C1 |
| 194 | 11000010 | C2 |
| 195 | 11000011 | C3 |
| 196 | 11000100 | C4 |
| 197 | 11000101 | C5 |
| 198 | 11000110 | C6 |
| 199 | 11000111 | C7 |
| 200 | 11001000 | C8 |
| 201 | 11001001 | C9 |
| 202 | 11001010 | CA |
| 203 | 11001011 | CB |
| 204 | 11001100 | CC |
| 205 | 11001101 | CD |
| 206 | 11001110 | CE |
| 207 | 11001111 | CF |
| 208 | 11010000 | D0 |
| 209 | 11010001 | D1 |
| 210 | 11010010 | D2 |
| 211 | 11010011 | D3 |
| 212 | 11010100 | D4 |
| 213 | 11010101 | D5 |
| 214 | 11010110 | D6 |
| 215 | 11010111 | D7 |
| 216 | 11011000 | D8 |
| 217 | 11011001 | D9 |
| 218 | 11011010 | DA |
| 219 | 11011011 | DB |
| 220 | 11011100 | DC |
| 221 | 11011101 | DD |
| 222 | 11011110 | DE |
| 223 | 11011111 | DF |
| 224 | 11100000 | E0 |
| 225 | 11100001 | E1 |
| 226 | 11100010 | E2 |
| 227 | 11100011 | E3 |
| 228 | 11100100 | E4 |
| 229 | 11100101 | E5 |
| 230 | 11100110 | E6 |
| 231 | 11100111 | E7 |
| 232 | 11101000 | E8 |
| 233 | 11101001 | E9 |
| 234 | 11101010 | EA |
| 235 | 11101011 | EB |
| 236 | 11101100 | EC |
| 237 | 11101101 | ED |
| 238 | 11101110 | EE |
| 239 | 11101111 | EF |
| 240 | 11110000 | F0 |
| 241 | 11110001 | F1 |
| 242 | 11110010 | F2 |
| 243 | 11110011 | F3 |
| 244 | 11110100 | F4 |
| 245 | 11110101 | F5 |
| 246 | 11110110 | F6 |
| 247 | 11110111 | F7 |
| 248 | 11111000 | F8 |
| 249 | 11111001 | F9 |
| 250 | 11111010 | FA |
| 251 | 11111011 | FB |
| 252 | 11111100 | FC |
| 253 | 11111101 | FD |
| 254 | 11111110 | FE |
| 255 | 11111111 | FF |
More free developer tools
FAQ
What is 10 in binary?+
1010. 10 = 8 + 2, so the 8s and 2s places are 1 and the 4s and 1s places are 0. Padded to a byte it is 00001010.
What is 255 in binary?+
11111111, eight 1 bits. 255 is the largest number that fits in one byte; 256 needs nine bits (100000000).
What is 100 in binary?+
1100100: 64 + 32 + 4. Padded to 8 bits it is 01100100.
What is the fastest way to convert decimal to binary by hand?+
For small numbers, subtract the largest power of two that fits (128, 64, 32, 16, 8, 4, 2, 1) and write 1 for each one you used, 0 for the rest. For any size, divide by 2 repeatedly and read the remainders from the bottom up. Both give the same answer.
How do I write a negative number in binary?+
Pick a width, write the positive number in that many bits, invert every bit and add 1. -5 in 8 bits: 00000101 → 11111010 → 11111011. Type -5 above and choose a width to see it.
How many bits do I need for a decimal number?+
floor(log2(n)) + 1 for a positive integer n, so 1,000 needs 10 bits and 1,000,000 needs 20. Add one bit if the number can be negative and you store it signed.
Can decimal fractions be converted to binary?+
Yes, by multiplying the fraction by 2 again and again and taking the whole part each time. 0.625 is 0.101. Many fractions never end, though: 0.1 is 0.0001100110011… in binary, which is why floating-point math rounds.
Sources: MDN: Number.prototype.toString() · MDN: String.prototype.padStart() · MDN: BigInt.asUintN() · Python: format specification · Go: fmt · GNU bc manual. Checked 2026-10-30.