Binary to Decimal Converter
Binary to decimal with each bit’s power of 2 and a running total, signed or unsigned, fractions included.
To convert decimal to binary, divide the number by 2 again and again and write down each remainder; the remainders read from the bottom up are the binary digits.
13 in binary
13 in decimal is 1101 in binary.
| Divide | Quotient | Remainder (bit) | Bit position |
|---|---|---|---|
| 13 ÷ 2 | 6 | 1 | 2⁰ |
| 6 ÷ 2 | 3 | 0 | 2¹ |
| 3 ÷ 2 | 1 | 1 | 2² |
| 1 ÷ 2 | 0 | 1 | 2³ |
Divide by 2 repeatedly
Keep dividing by 2 and write down each remainder: 13 ÷ 2 = 6 r 1; 6 ÷ 2 = 3 r 0; 3 ÷ 2 = 1 r 1; 1 ÷ 2 = 0 r 1. Stop when the quotient reaches 0.
Read the remainders from the bottom up
The first remainder is the rightmost bit (the 1s place) and the last is the leftmost: 13 = 1101₂.
Check with place values
The 1 bits sit at 2³, 2², 2⁰: 8 + 4 + 1 = 13.
Result
So 13 becomes 1101. Type any number to see every division, pad the answer to 8, 16, 32 or 64 bits, and convert negative numbers to two’s complement and decimals such as 0.625 to binary fractions.
Repeated division by 2
Plain-text formula: n = 2q + r, r ∈ {0, 1}
Divide n by 2 to get a quotient q and a remainder r. The remainder is the next bit, starting from the right. Repeat with q until it is 0. The bits come out from least significant to most significant, which is why the remainders are read from the bottom up.
Binary place values
Plain-text formula: n = b_k · 2^k + ⋯ + b_1 · 2^1 + b_0 · 2^0
Each bit is 0 or 1 and multiplies a power of 2. Writing a number in binary means finding which powers of 2 add up to it, which is what the subtraction method does directly.
Fraction bits: repeated multiplication by 2
Plain-text formula: 2f = b_(−1) + f_1, 0 ≤ f_1 < 1
For the part after the point, multiply by 2. The whole part of the product, 0 or 1, is the next bit after the point; continue with the fraction that is left. Stop when it reaches 0, or when a fraction repeats, in which case the bits repeat too.
Two’s complement of a negative number
Plain-text formula: pattern(−m) = 2^w − m
In a w-bit word, a negative number −m is stored as the binary form of 2^w − m. The same pattern comes from writing m in w bits, inverting every bit and adding 1.
The main result is the binary form of your number. With No padding, it has no leading zeros, so 13 is 1101. The panel also shows the same number padded to the smallest standard width, its hexadecimal and octal forms, and how many bits it needs: a whole number n needs one more bit than the highest power of 2 that fits in it.
With a bit width chosen, the answer always has exactly that many bits. For a positive number, the extra bits are leading zeros and do not change its value. For a negative number, the answer is the two’s complement pattern a computer stores: its top bit is 1, and the same bits read as unsigned give minus the number’s size, so −5 in 8 bits reads as 251 unsigned.
Divide the number by 2 and write down the remainder, which is always 0 or 1. Divide the quotient by 2 again, and keep going until the quotient is 0. The remainders, read from the last one up to the first, are the binary digits. The first remainder is the rightmost bit because it says whether the number is odd. In UK courses decimal is often called denary, so “denary to binary” means the same conversion.
For 13: 13 ÷ 2 = 6 remainder 1, 6 ÷ 2 = 3 remainder 0, 3 ÷ 2 = 1 remainder 1, and 1 ÷ 2 = 0 remainder 1. Reading the remainders from the bottom up gives 1101. Check: 8 + 4 + 1 = 13.
| Divide | Quotient | Remainder | Bit |
|---|---|---|---|
| 13 ÷ 2 | 6 | 1 | 2⁰ (rightmost) |
| 6 ÷ 2 | 3 | 0 | 2¹ |
| 3 ÷ 2 | 1 | 1 | 2² |
| 1 ÷ 2 | 0 | 1 | 2³ (leftmost) |
For numbers up to a few hundred, it is often faster to subtract powers of 2. Find the largest power of 2 that fits, write a 1 in its place, subtract it, and repeat with what is left. Every place you skip gets a 0.
For 224: 128 fits (224 − 128 = 96), 64 fits (96 − 64 = 32), 32 fits (32 − 32 = 0), and nothing is left, so the 16, 8, 4, 2 and 1 places are 0. That gives 224 = 11100000. For 25: 16 fits (9 left), 8 fits (1 left), 4 and 2 do not, and 1 fits, so 25 = 11001.
| Place value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
|---|---|---|---|---|---|---|---|---|
| Bit for 224 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 |
| Bit for 25 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 1 |
The table lists every number from 0 to 63, which covers all 6-bit values. Each extra bit doubles the range: 7 bits reach 127 and a full byte of 8 bits reaches 255. For any other number, type it into the converter above.
| Decimal | Binary | Decimal | Binary |
|---|---|---|---|
| 0 | 0 | 32 | 100000 |
| 1 | 1 | 33 | 100001 |
| 2 | 10 | 34 | 100010 |
| 3 | 11 | 35 | 100011 |
| 4 | 100 | 36 | 100100 |
| 5 | 101 | 37 | 100101 |
| 6 | 110 | 38 | 100110 |
| 7 | 111 | 39 | 100111 |
| 8 | 1000 | 40 | 101000 |
| 9 | 1001 | 41 | 101001 |
| 10 | 1010 | 42 | 101010 |
| 11 | 1011 | 43 | 101011 |
| 12 | 1100 | 44 | 101100 |
| 13 | 1101 | 45 | 101101 |
| 14 | 1110 | 46 | 101110 |
| 15 | 1111 | 47 | 101111 |
| 16 | 10000 | 48 | 110000 |
| 17 | 10001 | 49 | 110001 |
| 18 | 10010 | 50 | 110010 |
| 19 | 10011 | 51 | 110011 |
| 20 | 10100 | 52 | 110100 |
| 21 | 10101 | 53 | 110101 |
| 22 | 10110 | 54 | 110110 |
| 23 | 10111 | 55 | 110111 |
| 24 | 11000 | 56 | 111000 |
| 25 | 11001 | 57 | 111001 |
| 26 | 11010 | 58 | 111010 |
| 27 | 11011 | 59 | 111011 |
| 28 | 11100 | 60 | 111100 |
| 29 | 11101 | 61 | 111101 |
| 30 | 11110 | 62 | 111110 |
| 31 | 11111 | 63 | 111111 |
These are the values people look up most often, grouped in fours so they are easy to read and to turn into hexadecimal: each group of 4 bits is one hex digit. A number made of n ones, such as 1111 1111, is always , here 255, and a 1 followed by n zeros is .
| Decimal | Binary | Hex |
|---|---|---|
| 64 | 100 0000 | 40 |
| 100 | 110 0100 | 64 |
| 127 | 111 1111 | 7F |
| 128 | 1000 0000 | 80 |
| 192 | 1100 0000 | C0 |
| 200 | 1100 1000 | C8 |
| 224 | 1110 0000 | E0 |
| 240 | 1111 0000 | F0 |
| 250 | 1111 1010 | FA |
| 255 | 1111 1111 | FF |
| 256 | 1 0000 0000 | 100 |
| 500 | 1 1111 0100 | 1F4 |
| 512 | 10 0000 0000 | 200 |
| 1000 | 11 1110 1000 | 3E8 |
| 1023 | 11 1111 1111 | 3FF |
| 1024 | 100 0000 0000 | 400 |
Computers store numbers in fixed-size words: a byte is 8 bits, and common integer types are 16, 32 and 64 bits. Padding writes the number at that width by adding zeros on the left, which never changes the value: 13 is 1101, or 0000 1101 as a byte, or 0000 0000 0000 1101 as 16 bits.
A number only fits if it needs no more bits than the width allows. An unsigned 8-bit byte holds 0 to 255, 16 bits hold 0 to 65,535 and 32 bits hold 0 to 4,294,967,295. The converter warns you when a number does not fit, such as 256 in 8 bits, which needs 9.
Binary has no minus sign inside a computer. Instead, signed integers use two’s complement: write the size of the number in the chosen width, invert every bit, and add 1. For −5 in 8 bits: 5 = 0000 0101, inverted = 1111 1010, plus 1 = 1111 1011. A shortcut gives the same answer: , and 251 in binary is 1111 1011.
The width matters. −5 is 1111 1011 in 8 bits but 1111 1111 1111 1011 in 16 bits, because the extra bits copy the sign. A signed 8-bit number runs from −128 (1000 0000) to 127 (0111 1111). Written on paper without a fixed width, −5 is simply −101, and that is what the converter shows with no padding.
| Decimal | Size in binary | Inverted | Add 1 (8-bit pattern) |
|---|---|---|---|
| −1 | 0000 0001 | 1111 1110 | 1111 1111 |
| −5 | 0000 0101 | 1111 1010 | 1111 1011 |
| −16 | 0001 0000 | 1110 1111 | 1111 0000 |
| −100 | 0110 0100 | 1001 1011 | 1001 1100 |
| −128 | 1000 0000 | 0111 1111 | 1000 0000 |
For the part after the decimal point, multiply by 2 instead of dividing. The whole part of each product is the next bit after the binary point. For 0.625: 0.625 × 2 = 1.25, bit 1; 0.25 × 2 = 0.5, bit 0; 0.5 × 2 = 1, bit 1, and nothing is left. So 0.625 = 0.101, and 156.625 = 10011100.101.
Most decimal fractions never end in binary. 0.1 gives 0.2, 0.4, 0.8, 1.6, 1.2, 0.4 … and the bits 0011 repeat forever: 0.1 = 0.0(0011). A computer has to cut that off, which is why 0.1 + 0.2 is not exactly 0.3 in most programming languages. Only fractions whose denominator is a power of 2, such as ½, ¼ or ⅜, end in binary. Read more about floating point and rounding.
In Python, bin(13) returns 0b1101, and format(13, "08b") returns the padded byte 00001101. For a negative number in two’s complement, mask it to the width first: format(-5 & 0xFF, "08b") returns 11111011. Python’s bin(-5) gives -0b101, with a minus sign instead.
In JavaScript, (13).toString(2) returns 1101 and (13).toString(2).padStart(8, "0") pads it. (-5 >>> 0).toString(2) gives the 32-bit two’s complement pattern. In C there is no standard binary format before C23, which adds %b to printf; on older compilers, loop over the bits with (n >> i) & 1 from the top bit down.
In Excel and Google Sheets, =DEC2BIN(13) returns 1101 and =DEC2BIN(13, 8) returns 00001101. DEC2BIN accepts −512 to 511 only, and returns negatives as 10-bit two’s complement: =DEC2BIN(-5) is 1111111011. Use this converter for larger numbers or other widths.
Reading the remainders from the top down. The first remainder is the rightmost bit. Read from the top and 13 comes out as 1011, which is 11.
Stopping too early. Keep dividing until the quotient is 0. The last division, 1 ÷ 2 = 0 remainder 1, gives the leading 1 and is easy to miss.
Dropping zeros in the middle. Every place between the leading 1 and the end needs a bit. 224 is 11100000, not 111.
Mixing up the methods for fractions. Divide the whole part but multiply the fractional part, and read the fraction bits from the top down, the opposite order to the whole part.
Convert each number to binary, then check your answer in the table or by typing it into the converter, which shows every step.
| Question | Decimal | Binary | Working |
|---|---|---|---|
| 1 | 6 | 110 | 4 + 2 |
| 2 | 19 | 10011 | 16 + 2 + 1 |
| 3 | 42 | 101010 | 32 + 8 + 2 |
| 4 | 100 | 1100100 | 64 + 32 + 4 |
| 5 | 200 | 11001000 | 128 + 64 + 8 |
| 6 | 1000 | 1111101000 | 512 + 256 + 128 + 64 + 32 + 8 |
| 7 | 0.75 | 0.11 | 0.5 + 0.25 |
| 8 | −8 (8-bit) | 1111 1000 | 256 − 8 = 248 |
Write the decimal number 156 in binary, then as an 8-bit byte.
Answer: 156₁₀ = 10011100₂. In hexadecimal it is 9C, since 1001 = 9 and 1100 = C.
Divide the number by 2 repeatedly and write down each remainder until the quotient is 0. The remainders read from the bottom up are the binary number. For 13: remainders 1, 0, 1, 1 read upward give 1101.
224 is 11100000 in binary: 128 + 64 + 32 = 224, so the three highest places of a byte are 1 and the rest are 0. In hexadecimal it is E0. As a subnet mask octet, 224 means the first three bits are network bits.
25 is 11001 in binary, because 25 = 16 + 8 + 1. As an 8-bit byte it is 0001 1001.
2 is 10 in binary: a 1 in the 2s place and a 0 in the 1s place. Likewise 4 is 100, 8 is 1000 and 16 is 10000; every power of 2 is a 1 followed by zeros.
With a fixed width, use two’s complement: write the size in that many bits, invert every bit and add 1. −5 in 8 bits is 1111 1011. Without a fixed width, write a minus sign in front: −101.
A decimal fraction ends in binary only if its denominator, in lowest terms, is a power of 2. 0.1 is 1/10, and 10 has a factor of 5, so the bits 0011 repeat forever: 0.1 = 0.0001100110011… in binary.
A positive whole number n needs ⌊log₂ n⌋ + 1 bits. So 255 needs 8 bits and 256 needs 9. The converter lists the bit count under the answer.
Add the place values 1, 2, 4, 8, 16, … wherever the bit is 1: 1101 = 8 + 4 + 1 = 13. The binary to decimal converter shows this bit by bit.
Binary to decimal with each bit’s power of 2 and a running total, signed or unsigned, fractions included.
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.
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?