FLXCode Decimal to Binary Converter

FLXCode apps

Appearance

Decimal to Binary Converter

Type a whole number or a decimal. You get its binary form in groups of four bits and the divisions that produce it.

Example

1001 1100

156 in base 10 (decimal) is 10011100 in base 2 (binary).

Steps

  1. Divide by 2 again and again. The remainders, read from the last to the first, are the digits: 156 ÷ 2 = 78 remainder 0; 78 ÷ 2 = 39 remainder 0; 39 ÷ 2 = 19 remainder 1; 19 ÷ 2 = 9 remainder 1; 9 ÷ 2 = 4 remainder 1; 4 ÷ 2 = 2 remainder 0; 2 ÷ 2 = 1 remainder 0; 1 ÷ 2 = 0 remainder 1.

The same number in the common bases

BaseValue
base 2 (binary)1001 1100
base 8 (octal)234
base 10 (decimal)156
base 16 (hexadecimal)9C

No ads. No account. Nothing you type or record is uploaded. We count page events with a daily code. Check it.

Problem or idea? Email us

Worked examples

DecimalBinaryNote
101010Eight + two
1561001 1100The tool default: 128 + 16 + 8 + 4
2551111 1111Every bit of a byte set
10240100 0000 00002¹⁰: a 1 and ten zeros
0.6250.1015/8 ends in binary
0.10.0(0011)Never ends in binary, so a repeat is marked
-5-0101A minus sign in front, plus two's complement below the result

156 by repeated division

DivisionQuotientRemainder (a bit)
156 ÷ 2780
78 ÷ 2390
39 ÷ 2191
19 ÷ 291
9 ÷ 241
4 ÷ 220
2 ÷ 210
1 ÷ 201

Read the remainders from the bottom up: 10011100. That is 1001 1100 with the nibble grouping.

Negative numbers

For −5 the tool shows -0101 (sign and size) and then these fixed-width patterns:

  • 8-bit: hex FB, binary 1111 1011
  • 16-bit: hex FFFB, binary 1111 1111 1111 1011

To go back, use binary to decimal. For hexadecimal output change the To base to 16 or use hex to decimal in reverse. The number base converter has every base from 2 to 36.

Numbers this uses

  • Input: a whole or decimal number of up to 1,000 characters, with an optional minus sign.
  • Fraction digits stop at 64. A repeating fraction is shown with the repeat in brackets.
  • The divide-by-2 steps list the first 40 divisions.
  • Two's complement widths shown: 8, 16, 32 and 64 bits, when the value fits.

Nothing you type is uploaded. We count events without cookies (details).

FAQ

How do I convert decimal to binary by hand?

Divide the number by 2, write down the remainder (0 or 1), and divide the answer by 2 again. Stop at 0. Read the remainders from the last to the first. For 156 that gives 10011100. The table on this page shows each division.

What is the subtract-the-biggest-power method?

Find the largest power of 2 that fits, write 1 in that place, subtract it, and repeat with the rest. 156: 128 fits (1), 64 does not (0), 32 does not (0), 16 fits (1), 8 fits (1), 4 fits (1), 2 and 1 do not (00). That gives 10011100 again.

How do I write a negative number in binary?

Computers use two's complement: invert all the bits of the positive number and add 1, within a fixed width. −5 in 8 bits is 11111011. When you type a negative whole number the tool lists the 8, 16, 32 and 64-bit patterns. The main answer keeps the minus sign: -0101.

How many bits do I need?

The number of bits in the answer, rounded up to a width the machine uses (8, 16, 32, 64). 156 needs 8 bits. 1024 needs 11, so a 16-bit field. A signed number needs one more bit for the sign, so 156 will not fit in a signed byte, which stops at 127.

Why does 0.1 not end in binary?

A fraction ends in base 2 only when its bottom number, in lowest terms, is a power of 2. 0.1 = 1/10 has a 5 in the bottom, so it repeats: 0.0001100110011. The tool finds the repeating part, shows it in brackets, and stops at 64 digits if it has not found it.

Why is the answer shown in groups of four?

Four bits are one hex digit, so 1001 1100 is 9C. The tool pads the first group with zeros to fill it. The copy button gives the digits with no spaces, which is what you paste into code.

Can I convert a really large number?

Yes. The input can be up to 1,000 digits and the answer is exact, because the tool uses BigInt. 2⁶⁴ comes out as a 1 followed by 64 zeros. The 40-step division list is cut off for numbers with more than 40 bits, but the result is complete.

Does anything I type leave my browser?

No. The conversion is done on your device. What you type is not put in the address bar, not stored and not counted. We only count the base you converted to.

More from FLXCode

Share Decimal to Binary Converter