Number converter · Free · No sign-up
Decimal to Binary Converter
To convert decimal to binary, divide by 2 again and again, writing down each remainder, then read the remainders from the last to the first. 156 gives 0, 0, 1, 1, 1, 0, 0, 1, so it is 10011100. For a fraction, multiply by 2 and take each whole part. Negative numbers use two's complement.
Every division shown.
- Divide 156 by 2 again and again, writing down each remainder.
- 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
- Read the remainders from the last to the first: 10011100.
| Form | Value |
|---|---|
| Binary (base 2) | 10011100 |
| Octal (base 8) | 234 |
| Decimal (base 10) | 156 |
| Hexadecimal (base 16) | 9C |
| Binary in groups of four | 1001 1100 |
The figures above are an example: put in your own decimal number, such as 1,234.5 or -42. Spaces and underscores between digit groups are ignored, and 0b, 0o, 0x or # in front are read when they match the base. Worked out exactly in this browser and kept there; nothing is sent anywhere. Going the other way? Use binary to decimal.
Type a decimal number, including a fraction or a minus sign, and read the binary with each division by 2 listed. Turn on two's complement to see a negative number as the bit pattern a computer stores.
Decimal to binary conversion rewrites an everyday base-10 number in base 2, using only 0 and 1, by finding which powers of 2 add up to it.
- No sign-up
- Nothing uploaded
- Shows every step
- Works offline
- Exact, any size
Key facts
| Detail | Answer |
|---|---|
| Method shown | Divide by 2, keep the remainders, read them upwards |
| Example | 156 = 10011100 |
| Fractions | Multiply by 2 and keep the whole parts; 0.1 = 0.0(0011), repeating |
| Negative numbers | Two's complement at 8, 16, 32 or 64 bits: −42 = 11010110 at 8 bits |
| Size | Up to 256 characters, exact |
| Where your numbers are kept | This browser only |
How to convert decimal to binary by hand
Repeated division, the method the converter lists, works for any whole number.
Divide the number by 2
Write the whole-number answer and the remainder, 0 or 1.
Divide the answer by 2 again
Keep going until the answer is 0.
Read the remainders upwards
The last remainder is the leftmost bit.
For a fraction, multiply by 2
The whole part, 0 or 1, is the next bit after the point; keep the rest.
Stop when the fraction ends or repeats
A remainder seen before means the bits repeat from there.
For a negative, invert and add 1
At a fixed width, for two's complement.
Who converts decimal to binary
Anyone who needs to see the bits behind an ordinary number.
Students
Base-conversion homework with every division to compare.
Programmers
Bit masks, flags and shifts worked out from decimal.
Network engineers
Octets of an address or mask written as bits.
Electronics builders
Values for DIP switches, LEDs and registers.
Teachers
Worked examples, including why 0.1 repeats.
Game and puzzle makers
Binary clues made from a number.
Why 0.1 has no exact binary form
Whole numbers always convert to a finite string of bits. Decimal fractions mostly do not. A fraction ends in binary only if, in lowest terms, its denominator is a power of 2: 0.5 is 1/2, 0.75 is 3/4 and 0.625 is 5/8, so they end. 0.1 is 1/10, and 10 has a factor of 5, so the doubling never comes out even and the bits repeat for ever. The Python tutorial on floating point makes the same point: in base 2, 1/10 is an infinitely repeating fraction, and a computer stores only the nearest value it can hold, which is why 0.1 + 0.1 + 0.1 does not compare equal to 0.3 in most languages.
| Decimal | As a fraction | Binary | Ends? |
|---|---|---|---|
| 0.5 | 1/2 | 0.1 | Yes |
| 0.25 | 1/4 | 0.01 | Yes |
| 0.75 | 3/4 | 0.11 | Yes |
| 0.625 | 5/8 | 0.101 | Yes |
| 0.1 | 1/10 | 0.0(0011) | No, 0011 repeats |
| 0.2 | 1/5 | 0.(0011) | No |
| 0.3 | 3/10 | 0.0(1001) | No |
| 0.375 | 3/8 | 0.011 | Yes |
The converter follows the multiplication until the fraction ends or a remainder comes round again, then puts the repeating block in brackets, so 0.1 is shown exactly as 0.0(0011) rather than as 20 rounded digits. If the repeat is longer than 64 places, the result is cut there with an ellipsis and the working says so.
The other method: subtract powers of 2
Repeated division is the method most courses teach, but there is another that many people find easier for numbers under a few thousand: take away the largest power of 2 that fits, mark a 1 in its place, and repeat with what is left. Every power you skip is a 0.
| Power of 2 | Fits into what is left? | Bit | Left over |
|---|---|---|---|
| 128 | Yes, 156 − 128 | 1 | 28 |
| 64 | No | 0 | 28 |
| 32 | No | 0 | 28 |
| 16 | Yes, 28 − 16 | 1 | 12 |
| 8 | Yes, 12 − 8 | 1 | 4 |
| 4 | Yes, 4 − 4 | 1 | 0 |
| 2 | No | 0 | 0 |
| 1 | No | 0 | 0 |
Reading the bit column down gives 10011100, the same as the remainders read upwards in the converter’s working. The subtraction method shows directly which powers make up the number (156 = 128 + 16 + 8 + 4), which is handy for bit flags and permission masks.
Negative numbers: two's complement step by step
Binary has no minus sign inside a computer. A negative number is stored as a two’s complement pattern of a fixed width: write the positive number in that width, invert every bit, and add 1. Choose a width in the converter and it does exactly that, with each step shown, and refuses a number that does not fit.
| Decimal | 8-bit | 16-bit |
|---|---|---|
| −1 | 1111 1111 | 1111 1111 1111 1111 |
| −2 | 1111 1110 | 1111 1111 1111 1110 |
| −42 | 1101 0110 | 1111 1111 1101 0110 |
| −100 | 1001 1100 | 1111 1111 1001 1100 |
| −128 | 1000 0000 | 1111 1111 1000 0000 |
| −129 | Does not fit | 1111 1111 0111 1111 |
Widening a negative number copies its sign bit into the new places (sign extension), which is why −42 gains eight 1s in 16 bits rather than eight 0s. Positive numbers gain 0s. The Cornell notes on two’s complement show the same invert-and-add-one rule at 8 and 32 bits.
Common decimal numbers in binary
Some values come up again and again in computing, because they are powers of 2 or one less than one.
| Decimal | Binary | Why it matters |
|---|---|---|
| 10 | 1010 | The usual first exercise |
| 15 | 1111 | The largest 4-bit value: one hex digit, F |
| 16 | 10000 | 24 |
| 100 | 1100100 | Seven bits |
| 127 | 1111111 | The largest signed byte |
| 128 | 10000000 | 27, the top bit of a byte |
| 255 | 11111111 | The largest byte; each part of 255.255.255.0 |
| 256 | 100000000 | 28: the first number a byte cannot hold |
| 1000 | 1111101000 | Ten bits |
| 1024 | 10000000000 | 210: one kibi, as in KiB |
1024 is the binary thousand. Because 210 is close to 1,000, it was long used for a kilobyte; NIST’s page on binary prefixes records that the IEC named it the kibi (KiB) in 1998 so that kilo can keep meaning exactly 1,000.
What this page does not do
This page turns a decimal number into base 2. It does not turn text into binary letter codes, and it does not show the IEEE 754 bit layout a computer uses to store 0.1 as a float; it shows the true binary value, repeating digits and all. Up to 256 characters, worked exactly.
To write a whole word in binary, one byte per letter, use the text to binary converter instead; A is 01000001 there.
| It does | It does not |
|---|---|
| Whole numbers of any size, exactly | Round through floating point |
| Decimal fractions, repeats marked | Encode text as binary |
| Negatives in 8, 16, 32 or 64-bit two’s complement | Show float or double bit layouts |
This converter or a typical one
| This page | A typical one | |
|---|---|---|
| Every division shown | Yes, numbered | A table at best |
| Decimal fractions | Exact, repeating bits marked | Rounded or refused |
| Negative numbers | Two's complement at your width, step by step | Often one fixed width, no steps |
| Numbers past 253 | Exact | Often rounded |
| Your numbers leave the browser | Never | Varies |
More converters
Every converter on the site runs in your browser, needs no sign-up, and sends nothing anywhere.
Numbers & code6
Binary, hex, octal and any base, number systems, and codes generated in the browser.
Decimal to hex
Division by 16 with A to F named, RGB channels to a #RRGGBB code, and negatives as hex patterns.
Open decimal to hex →Hex to decimal
Powers of 16 shown, #RGB to #RRGGBBAA colour codes read as channels, signed bytes and 0x addresses.
Open hex to decimal →Password generator
Random characters or EFF-word passphrases from the browser's crypto, no modulo bias, exact entropy, nothing sent.
Open password generator →ASCII, hex, binary, decimal converter
Text and byte codes both ways in one box, UTF-8 beyond 127 shown byte by byte, control characters named, Base64.
Open ascii, hex, binary, decimal converter →Binary converter
Binary, octal, decimal, hex or any base 2 to 36, exact at any size, fractions and two's complement, with steps.
Open binary converter →Binary to decimal
Each bit times its power of 2, binary fractions after the point, and signed patterns read at 8 to 64 bits.
Open binary to decimal →
All 31 converters, by category: Length (10) · Weight & mass (5) · Temperature (3) · Cooking (1) · Currency (1) · Numbers & code (7) · Text (2) · Images (1) · Dates & time (1)
Frequently asked questions
How do you convert decimal to binary?
Divide the number by 2 and write down the remainder, 0 or 1. Divide the answer by 2 again and repeat until it reaches 0. Read the remainders from the last one to the first. For 13: remainders 1, 0, 1, 1, so 13 is 1101. The converter lists every division.
What is 10 in binary?
10 in decimal is 1010 in binary: 8 + 2. Dividing gives remainders 0, 1, 0, 1, read upwards as 1010. As one byte it is written 00001010, with leading zeros that do not change the value. In hex the same number is A.
What is 255 in binary?
255 is 11111111: eight 1s, the largest value that fits in one byte, because 2^8 - 1 = 255. That is why each part of an IPv4 address or a colour channel stops at 255. 256 needs a ninth bit: 100000000.
How do you convert a decimal fraction to binary?
Multiply the fraction by 2. The whole part, 0 or 1, is the next bit after the point; keep the fractional part and repeat. 0.625 gives 1.25, then 0.5, then 1.0, so it is 0.101. Most fractions such as 0.1 never come out even and repeat for ever.
How do you write a negative number in binary?
Inside a computer, as a two's complement pattern of fixed width. Write the positive number in that many bits, invert every bit and add 1. -42 in 8 bits: 00101010, inverted 11010101, plus 1 gives 11010110. On paper you can also just write a minus sign: -101010.
Why is 0.1 + 0.2 not exactly 0.3 in programming?
Because 0.1 and 0.2 repeat for ever in binary, a computer stores the nearest binary fraction it can hold, slightly off. The two small errors add up, and the sum is not the stored value nearest to 0.3. This converter shows the true repeating binary instead of a rounded one.
What is 100 in binary?
100 is 1100100 in binary: 64 + 32 + 4. It needs seven bits because 64 is the largest power of 2 below 100. As a byte it is 01100100. In hex it is 64, which is easy to mix up with decimal 64.
How many bits does a decimal number need?
Find the largest power of 2 that is not more than the number; the bit count is that power's exponent plus one. 1000 is between 512 (2^9) and 1024 (2^10), so it needs 10 bits. A signed number needs one extra bit for the sign.
Related guides
Longer answers to the questions behind the numbers.
- Counting
Count to 1,023 on your fingers
The value of each of ten fingers, worked examples, how to count up, and why the top is 1,023.
- Reference
Types of counters explained
Synchronous vs asynchronous, mod-N, ring and Johnson, industrial and PLC counters, plus mechanical and software counters.
- Tallying
Tally marks explained
Groups of five, the five-bar gate, and why the convention has survived for centuries.
- Tallying
Tally marks in Excel and Google Sheets
The REPT, INT and MOD formula for five-bar gates, tested on every count from 0 to 120; a tally chart from raw answers with COUNTIF; and why LEN miscounts typed tallies.
- Counting
Why word counts differ between tools
The same sentence is 26 words to one counter and 39 to another. Four counting rules side by side, and how to meet a hard limit whichever one a form uses.