StringMash.com

Decimal to binary converter

Decimal numbers to binary, with every division shown.

Conversion
3 characters
Updates as you type
Swap for binary to decimal

Show the steps
  1. 156 ÷ 2 = 78 remainder 0
  2. 78 ÷ 2 = 39 remainder 0
  3. 39 ÷ 2 = 19 remainder 1
  4. 19 ÷ 2 = 9 remainder 1
  5. 9 ÷ 2 = 4 remainder 1
  6. 4 ÷ 2 = 2 remainder 0
  7. 2 ÷ 2 = 1 remainder 0
  8. 1 ÷ 2 = 0 remainder 1
  9. Read the remainders from the bottom up: 10011100
Printable chart

Using the converter

Type a decimal number and the binary appears as you type. Binary can come back as one run of bits or in groups of four. Several numbers can go in at once, separated by spaces, commas or new lines. Prefixes like 0x and 0b are fine, and so is the _ character used to group digits, as in 1001_1100. Numbers can be as long as you like and can be negative, but they have to be whole: there's no decimal point.

To turn words into binary rather than numbers, use the text to binary converter.

Show the steps opens the working under the answer, line by line, the same way you'd set it out on paper. It shows the first four numbers when there are several.

Decimal to another base: divide and keep the remainders

Divide the number by the base you're converting to, and write down the remainder. Divide the answer by the base again, and keep going until the answer is 0. The remainders, read from the last one back up to the first, are the digits of the new number.

For 13 in binary: 13 ÷ 2 is 6 remainder 1, 6 ÷ 2 is 3 remainder 0, 3 ÷ 2 is 1 remainder 1, and 1 ÷ 2 is 0 remainder 1. Reading up from the bottom gives 1101.

Hex works the same way, dividing by 16. A remainder from 10 to 15 is written as a letter, A to F, so 255 ÷ 16 is 15 remainder 15, and both 15s become F, giving FF.

The other way: subtract powers of two

Some people find it quicker to work from the top. Find the largest power of two that fits, 128 for 156, and write a 1. Take it away, leaving 28, and go down the powers: 64 doesn't fit, 0; 32 doesn't, 0; 16 does, 1, leaving 12; 8 does, 1, leaving 4; 4 does, 1, leaving 0; then 0 for 2 and 0 for 1. That gives 10011100, the same answer the division reaches.

THE FIRST 33 NUMBERS

Decimal, binary, octal and hex from 0 to 32

DecimalBinaryOctalHex
0000
1111
21022
31133
410044
510155
611066
711177
81000108
91001119
10101012A
11101113B
12110014C
13110115D
14111016E
15111117F
16100002010
17100012111
18100102212
19100112313
20101002414
21101012515
22101102616
23101112717
24110003018
25110013119
2611010321A
2711011331B
2811100341C
2911101351D
3011110361E
3111111371F
321000004020

Questions

What is 10 in binary?

1010, which is 8 + 2.

How do I write a negative number in binary?

On paper, with a minus sign, which is what this converter does. Computers usually store negative numbers another way, called two's complement, which depends on how many bits the number has.

Why does 5 come out as 0101 in groups of four?

Grouping pads the front with zeros so every group has four bits. It doesn't change the value.