Decimal to Binary Converter
Decimal to binary with each division by 2, padding to 8–64 bits, two’s complement and fractions.
To convert binary to decimal, multiply each bit by its power of 2 and add the results: binary 1101 = 8 + 4 + 0 + 1 = 13.
1101 in decimal
1101 in binary is 13 in decimal.
| Bit | Power of 2 | Place value | Adds | Running total |
|---|---|---|---|---|
| 1 | 2³ | 8 | 8 | 8 |
| 1 | 2² | 4 | 4 | 12 |
| 0 | 2¹ | 2 | 0 | 12 |
| 1 | 2⁰ | 1 | 1 | 13 |
Give each bit its place value
From the right of the number, the places are worth 1, 2, 4, 8, 16, … (powers of 2). Multiply each bit by its place value.
Add the place values where the bit is 1
8 + 4 + 1 = 13.
Check with the doubling method
Start at 0 and, for each bit from the left, double the total and add the bit: 0 × 2 + 1 = 1; 1 × 2 + 1 = 3; 3 × 2 + 0 = 6; 6 × 2 + 1 = 13.
Result
Type any binary number to see the place value of every bit and the running total. The converter also reads signed two’s complement values at 8, 16, 32 or 64 bits and binary fractions such as 101.11.
Binary to decimal formula
Plain-text formula: (b_(n − 1)…b_1b_0)_2 = b_(n − 1) · 2^(n − 1) + ⋯ + b_1 · 2^1 + b_0 · 2^0
Each bit is multiplied by 2 raised to its position, counting the rightmost bit as position 0. Since every bit is 0 or 1, this is the sum of the place values where the bit is 1.
Bits after the point
Plain-text formula: (0.b_(−1)b_(−2)b_(−3)…)_2 = b_(−1) · 2^(−1) + b_(−2) · 2^(−2) + b_(−3) · 2^(−3) + ⋯
Places after the point are worth ½ = 0.5, ¼ = 0.25, ⅛ = 0.125 and so on, halving each step. A binary fraction always has a decimal value that ends.
Two’s complement (signed) value
Plain-text formula: v = {u, if the top bit is 0; u − 2^w, if the top bit is 1
Read the bits as an unsigned number u first. If the leftmost of the w bits is 1, subtract 2^w to get the signed value.
The main result is the decimal value. With Read as set to unsigned, the bits are a plain positive number. The panel also lists the signed value: the same bits read as two’s complement at the chosen width. If the top bit is 0, both readings agree. If it is 1, the signed value is the unsigned value minus , so 1111 1011 is 251 unsigned and 251 − 256 = −5 signed.
With the width set to “As typed”, the bit count is exactly what you entered, leading zeros included: 1011 is −5 as a 4-bit number, but 0000 1011 is +11 as an 8-bit number. Pick 8, 16, 32 or 64 to match a byte, a short, an int or a long in code.
Write the place values above the bits, starting with 1 on the right and doubling each step to the left: 1, 2, 4, 8, 16, 32, 64, 128. Then add the place values that sit above a 1 and skip the ones above a 0. This is the positional method, and it works for any length.
For example, 1001 = 8 + 1 = 9, 10 = 2, 10110 = 16 + 4 + 2 = 22 and 1111 = 8 + 4 + 2 + 1 = 15. A quick check: a binary number ending in 0 is always even in decimal, and one ending in 1 is always odd.
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Bit | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 |
| Adds | 128 | 0 | 32 | 16 | 0 | 4 | 2 | 0 |
The doubling method avoids writing out the place values, which helps with long numbers or mental arithmetic. Start with 0. For each bit, from left to right, double the running total and add the bit. The last total is the decimal value. Some textbooks call this “double dabble”, though in computing that name also refers to a related binary-to-BCD circuit.
For 101101: 0 × 2 + 1 = 1, 1 × 2 + 0 = 2, 2 × 2 + 1 = 5, 5 × 2 + 1 = 11, 11 × 2 + 0 = 22, 22 × 2 + 1 = 45. So 101101 is 45, the same answer the place values give (32 + 8 + 4 + 1 = 45).
Every place value in binary is a power of 2. The values below cover common word sizes: a byte is 8 bits, so its top place is , and a number made of n ones is always , such as 11111111 = 255.
| Bit position | Power of 2 | Decimal value |
|---|---|---|
| 0 | 2⁰ | 1 |
| 1 | 2¹ | 2 |
| 2 | 2² | 4 |
| 3 | 2³ | 8 |
| 4 | 2⁴ | 16 |
| 5 | 2⁵ | 32 |
| 6 | 2⁶ | 64 |
| 7 | 2⁷ | 128 |
| 8 | 2⁸ | 256 |
| 9 | 2⁹ | 512 |
| 10 | 2¹⁰ | 1,024 |
| 11 | 2¹¹ | 2,048 |
| 12 | 2¹² | 4,096 |
| 15 | 2¹⁵ | 32,768 |
| 16 | 2¹⁶ | 65,536 |
| 31 | 2³¹ | 2,147,483,648 |
| 32 | 2³² | 4,294,967,296 |
| 63 | 2⁶³ | 9,223,372,036,854,775,808 |
The table lists 0 to 31 (every 5-bit number) and the byte values people look up most often. For any other number, type it into the converter above.
| Binary | Decimal | Binary | Decimal |
|---|---|---|---|
| 0 | 0 | 10000 | 16 |
| 1 | 1 | 10001 | 17 |
| 10 | 2 | 10010 | 18 |
| 11 | 3 | 10011 | 19 |
| 100 | 4 | 10100 | 20 |
| 101 | 5 | 10101 | 21 |
| 110 | 6 | 10110 | 22 |
| 111 | 7 | 10111 | 23 |
| 1000 | 8 | 11000 | 24 |
| 1001 | 9 | 11001 | 25 |
| 1010 | 10 | 11010 | 26 |
| 1011 | 11 | 11011 | 27 |
| 1100 | 12 | 11100 | 28 |
| 1101 | 13 | 11101 | 29 |
| 1110 | 14 | 11110 | 30 |
| 1111 | 15 | 11111 | 31 |
| 100000 | 32 | 1111111 | 127 |
| 1000000 | 64 | 10000000 | 128 |
| 1100100 | 100 | 11001000 | 200 |
| 11111110 | 254 | 11111111 | 255 |
| 100000000 | 256 | 1111101000 | 1,000 |
Computers store negative integers in two’s complement. In a w-bit word the top bit carries the place value instead of , so the same bits can mean two different numbers. In 8 bits, 1000 0000 is 128 unsigned and −128 signed, and 1111 1111 is 255 unsigned and −1 signed.
To read a signed value by hand, convert the bits as usual, and if the top bit is 1, subtract : 1111 1011 = 251, and 251 − 256 = −5. The same answer comes from inverting the bits and adding 1 (0000 0100 + 1 = 0000 0101 = 5), then putting a minus sign in front. The width matters: 1111 1011 as a 16-bit number is 0000 0000 1111 1011, which is +251.
| 8-bit pattern | Unsigned | Signed (two’s complement) |
|---|---|---|
| 0000 0000 | 0 | 0 |
| 0000 0001 | 1 | 1 |
| 0111 1111 | 127 | 127 |
| 1000 0000 | 128 | −128 |
| 1000 0001 | 129 | −127 |
| 1111 1011 | 251 | −5 |
| 1111 1110 | 254 | −2 |
| 1111 1111 | 255 | −1 |
Bits after the binary point have place values ½, ¼, ⅛, and so on. So 101.11 = 4 + 1 + 0.5 + 0.25 = 5.75, and 0.011 = 0.25 + 0.125 = 0.375. Every binary fraction has a decimal value that ends, because each place value is 1 divided by a power of 2.
The reverse is not true: many short decimals, such as 0.1, repeat forever in binary. That is why 0.1 + 0.2 is not exactly 0.3 in most programming languages. To convert a decimal fraction to binary, use the number base converter.
An IPv4 address is 32 bits written as four 8-bit groups called octets. To convert it, convert each octet on its own and keep the dots: 11000000 = 128 + 64 = 192, 10101000 = 128 + 32 + 8 = 168, and 00000001 = 1, so 11000000.10101000.00000001.00000001 is 192.168.1.1. Each octet runs from 0 (00000000) to 255 (11111111).
Subnet masks work the same way: 11111111.11111111.11111111.00000000 is 255.255.255.0, a /24 mask, because it starts with 24 ones. Besides 0, the only octet values a mask can contain are 128, 192, 224, 240, 248, 252, 254 and 255, the running totals of 128 + 64 + 32 + … from the left. Paste a dotted binary address into the converter to see every octet worked out.
In Python, int("1101", 2) returns 13 and also accepts a 0b prefix; 0b1101 typed directly is 13 too. In JavaScript, parseInt("1101", 2) returns 13; for more than 53 bits use BigInt("0b" + bits) to keep every digit. In C and C++, strtoul("1101", NULL, 2) returns 13.
In Excel and Google Sheets, =BIN2DEC("1101") returns 13. BIN2DEC accepts at most 10 bits and reads a 10-bit input with a leading 1 as negative two’s complement, so =BIN2DEC("1111111111") is −1. Use this converter for longer numbers or a different width.
Starting the powers at the left. The rightmost bit is , not the leftmost. Count positions from the right, or the answer comes out far too large.
Starting at 2 instead of 1. The first place value is . Writing 2, 4, 8, … for the places makes every answer twice too big, and odd numbers become impossible.
Mixing signed and unsigned. 1111 1111 is 255 or −1 depending on whether it is read as signed. Check which reading your course or code uses, and at which bit width.
Ignoring the width for signed numbers. 1011 is −5 as a 4-bit signed number but 11 as an 8-bit one, because the 8-bit pattern is 0000 1011 and its top bit is 0.
Convert each binary number to decimal, then check your answer in the table or by typing it into the converter, which shows the full working.
| Question | Binary | Answer | Working |
|---|---|---|---|
| 1 | 111 | 7 | 4 + 2 + 1 |
| 2 | 1010 | 10 | 8 + 2 |
| 3 | 11001 | 25 | 16 + 8 + 1 |
| 4 | 100101 | 37 | 32 + 4 + 1 |
| 5 | 1100100 | 100 | 64 + 32 + 4 |
| 6 | 10000001 | 129 | 128 + 1 |
| 7 | 0.101 | 0.625 | 0.5 + 0.125 |
| 8 | 1111 0000 (signed 8-bit) | −16 | 240 − 256 |
Write the binary number 101101 in base 10.
Answer: 101101₂ = 45₁₀. In hexadecimal it is 2D, since 0010 = 2 and 1101 = D.
Multiply each bit by 2 raised to its position, counting from 0 on the right, and add the results. In practice, add the place values 1, 2, 4, 8, 16, … wherever the bit is 1. For example 1101 = 8 + 4 + 1 = 13.
1001 in binary is 9 in decimal: 1 × 8 + 0 × 4 + 0 × 2 + 1 × 1 = 8 + 1 = 9.
Binary 10 is 2 in decimal. The left bit is in the 2s place and the right bit is in the 1s place, so 10 = 1 × 2 + 0 × 1 = 2. Likewise binary 100 is 4 and 1000 is 8.
11111111 is 255 as an unsigned number: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1, or 2⁸ − 1. Read as a signed 8-bit two’s complement number, the same bits are −1.
Bits after the point are worth ½, ¼, ⅛ and so on. So 101.11 = 4 + 1 + 0.5 + 0.25 = 5.75. The converter accepts the point and shows each fractional place value.
Divide by 2 repeatedly and read the remainders from the last to the first. For 13: 13 ÷ 2 = 6 r 1, 6 ÷ 2 = 3 r 0, 3 ÷ 2 = 1 r 1, 1 ÷ 2 = 0 r 1, so 13 = 1101. The decimal to binary converter shows these steps for any number.
A positive number n needs ⌊log₂ n⌋ + 1 bits. So 255 needs 8 bits and 256 needs 9. With n bits you can write 0 to 2ⁿ − 1 unsigned, or −2ⁿ⁻¹ to 2ⁿ⁻¹ − 1 signed.
Decimal to binary with each division by 2, padding to 8–64 bits, two’s complement and fractions.
Hex to decimal with place-value steps, plus binary, octal and any base 2 to 36, fractions included.
Binary addition, subtraction and bitwise operations with steps, at 8 to 64 bits, signed or unsigned.
a mod n with steps, negative numbers, power mod and modular inverses.
Numbers and dates to Roman numerals and back, with a chart, symbol breakdowns and strict validation.
Type or tap expressions with exact fractions, memory, variables, constants and complex mode.
Results are calculated in your browser with methods checked by automated tests, and are intended for learning and general use. For engineering, medical, financial, legal or safety-critical decisions, verify important values independently and follow the rounding rules your work requires. How accurate are these results?