Decimal to Binary Converter

Decimal to Binary Converter. Type your number into Decimal Input and the Decimal to Binary Converter instantly returns its Binary Output. Enter a message into the text to hex converter and it maps every character to its hexadecimal code point automatically.

Type any whole number into the decimal to binary converter, click the Convert button, and you get the base 2 result in a fraction of a second, along with the division steps that produced it. This free online tool also explains the method behind the answer, so you can check a conversion by hand, handle negative and fractional values, and understand why computers store every number as a string of digits made of only 0 and 1.

What Is Decimal to Binary Conversion?

Decimal to binary conversion rewrites a number from the base 10 system you use every day into base 2, the system that digital hardware actually stores. The value stays exactly the same; only the notation changes. The decimal number 357 and the binary number 101100101 describe the same quantity, the same way "seven" and "VII" do.

Both notations are built on the same idea. Each digit has a weight, and the number is the sum of every digit multiplied by its weight. In decimal the weights are powers of ten, and in binary they are powers of two. That is why the binary number for any whole value is just a list of which powers of two you need to add together.

The Decimal System and the Binary System in Number Conversion

The decimal numeral system has ten symbols, 0 through 9, and each position is worth ten times the position to its right. In the 3-digit value 357, the 3 sits in the hundreds place, which is a power of 10, so the number equals \(3 \times 10^{2} + 5 \times 10^{1} + 7 \times 10^{0}\). The Hindu-Arabic numeral system made this positional approach the standard way to write numbers.

The binary numeral system has only two symbols, 0 and 1, and each position is worth twice the one to its right. Every binary digit is a single position, and the rightmost one carries the weight \(2^{0}\). Several ancient civilizations experimented with two-state counting, but modern electronics made it universal: a transistor or an electric signal is either on or off, so this positional system is the natural language of electronics, which is why a base converter between the two is one of the first tools a student of computing reaches for. The result is the binary code that machines read directly.

  • The radix (base) of decimal is 10 and the radix of binary is 2.
  • A decimal number needs ten symbols; a binary number needs two.
  • Reading the weights from right to left gives 1, 2, 4, 8, 16, 32 and so on, doubling every step.
Dumbbell chart comparing how many decimal digits and binary digits the largest 2, 4, 6, 8 and 10 digit numbers need
A binary number needs about 3.3 times as many digits as its decimal equivalent.

How to Use the Decimal to Binary Converter

The converter takes one decimal value and returns its binary form in a single action. Follow these steps:

  1. Type your whole or fractional decimal number into the input field, using a period for the radix point.
  2. Set the number of fractional bits only if your value has a fractional part.
  3. Click the Convert button to see the binary result.
  4. Click Clear to reset the form, or simply type over the old value and convert again.

Everything the decimal to binary converter tool returns can be reproduced by hand, and a binary calculator is useful for the arithmetic that follows once your decimal numbers to binary are ready, which is exactly what the next section covers. If you want to go the other way, a binary to decimal converter reverses the same steps, and a decimal to hex converter or decimal to octal converter applies the same method with a different radix.

How to Convert Decimal to Binary by Hand

There are two classic ways to convert decimal to binary on paper: repeated division and repeated subtraction. Both give the same answer, so pick whichever feels clearer to you.

Division Method: Step-by-Step

The division method is the one most programs use. It works because each division by 2 peels off the least significant bit of the number. The conversion steps are:

  1. Divide the decimal number by 2.
  2. Write down the remainder, which is always 0 or 1. It becomes one binary digit.
  3. Use the integer quotient as the new number and repeat.
  4. Stop when the quotient reaches 0, then read the remainders in reverse order, from bottom to top.

In formula form, for a number \(N\) the binary digits \(b_{k}\) are the remainders of repeated division:

$$b_{k} = \left\lfloor \frac{N}{2^{k}} \right\rfloor \bmod 2$$

Conversion Examples: Converting 357 to Binary

Conversion Examples: Converting 357 to Binary
Division by 2QuotientRemainderBit
357 ÷ 217810
178 ÷ 28901
89 ÷ 24412
44 ÷ 22203
22 ÷ 21104
11 ÷ 2515
5 ÷ 2216
2 ÷ 2107
1 ÷ 2018

Reading the remainders from the bottom row to the top gives 35710 = 1011001012. The number needs nine binary digits because 357 sits between \(2^{8} = 256\) and \(2^{9} = 512\).

Subtraction Method

The subtraction method uses the powers of 2 directly. List the powers of 2 that are no larger than your number, then walk down from the biggest: if the power fits, subtract it and write 1; if not, write 0. For 357 the powers are 256, 128, 64, 32, 16, 8, 4, 2 and 1:

  • 357 − 256 = 101, so write 1 for 256.
  • 128 does not fit into 101, so write 0.
  • 101 − 64 = 37, so write 1; then 37 − 32 = 5, so write 1 for 32.
  • 16 and 8 do not fit into 5, so write 0 twice.
  • 5 − 4 = 1, so write 1; 2 does not fit, so write 0; 1 − 1 = 0, so write 1.

The digits 1 0 1 1 0 0 1 0 1 match the division method exactly. The division method is easier to automate; the subtraction method shows you the structure of the answer, because each 1 marks a power of 2 that is part of the sum: \(357 = 256 + 64 + 32 + 4 + 1\).

Waterfall chart showing the decimal number 357 built from the powers of 2 256, 64, 32, 4 and 1, which gives binary 101100101
The decimal number 357 is the sum of five powers of 2, and each one becomes a 1 in its binary form.

Decimal to Binary Conversion in Practice: Reading a Subnet Mask Octet

Marisol is setting up a small office network and needs to split 192.168.40.0 into subnets of 30 usable hosts each. Her router's form wants the last octet of the mask, and she already knows the answer should be 224. What she does not trust is her memory of why, so she opens the converter and enters 224.

The decimal octet is now a binary number, and the result comes back as 11100000: three 1s followed by five 0s. That tells her the network portion uses 3 extra bits, which makes the full mask /27, and the five remaining 0 bits are the host portion. The binary conversion shows the structure that the decimal number hides.

The binary form is what makes the host count readable: five 0 bits give \(2^{5} = 32\) addresses, minus network and broadcast, so 30 usable hosts, which meets the requirement exactly. A 31st device would need a 6th host bit, which means a /26 mask (255.255.255.192, or 11000000 in the last octet).

Before committing, Marisol runs one more check, entering 192 to confirm the /26 pattern 11000000 would give 62 hosts. Seeing both results side by side, she keeps 224 for now and writes a note to move to 192 if the office passes 30 devices. A single conversion turned a remembered number into a decision with a named limit.

Decimal to Binary Conversion Table

A quick conversion table is handy when you only need the common values. The table below lists the powers of 2 that every other decimal to binary conversion is built from, with the hexadecimal digit alongside.

Decimal to Binary Conversion Chart

Decimal to Binary Conversion Chart
DecimalPower of 2BinaryHex
12011
221102
4221004
82310008
16241000010
322510000020
6426100000040
128271000000080
512291000000000200
102421010000000000400

Any value that is not a power of 2 is a sum of these rows. For example, 357 is the 256, 64, 32, 4 and 1 rows added together, which is exactly the 101100101 you saw above.

Decimal to Binary Conversion in Programming

Developers rarely convert by hand, but every language exposes the same logic. Understanding it helps you debug bit masks, flags and file formats.

Python

Python's built-in bin() function returns a string prefixed with 0b, so slice the prefix off when you only want the digits:

n = 357
print(bin(n)[2:])      # 101100101
print(format(n, "b"))  # 101100101

Java

Java offers Integer.toBinaryString, and you can also build the answer yourself with a loop and a StringBuilder, appending n % 2 and then reversing the string:

String bits = Integer.toBinaryString(357); // "101100101"

Both approaches rely on bitwise arithmetic or the same remainder-and-quotient loop described earlier, so what the program prints should always match what the converter shows.

Binary Conversion of Negative and Fractional Decimal Numbers

Two's Complement for Negative Numbers

Computers store negative integers in two's complement. Convert the absolute value, flip the bits, then add 1 to the least significant bit. To store −37 in 8 bits: 37 is 00100101, flipping gives 11011010, and adding 1 gives 11011011.

Fractional Values and the Radix Point

A fractional decimal value is converted in two parts. The whole part uses the division method. The fraction after the radix point uses repeated multiplication: multiply by 2, record the whole number part (0 or 1), keep the fraction, and repeat. For 12.375 the whole part 12 becomes 1100, and the fraction gives 0.375 × 2 = 0.75 (0), 0.75 × 2 = 1.5 (1), 0.5 × 2 = 1.0 (1), so the result is 1100.011.

Some fractions end cleanly, which are the dyadic fractions, such as 0.375. Others never end: decimal 0.2 becomes 0.001100110011… with a repeating pattern, so any converter must keep it truncated at the number of bits you ask for. An arbitrary-precision tool can show hundreds of digits, while a standard floating-point type keeps only a fixed width, which is why a value like 0.2 carries a tiny precision error in most programming languages.

Binary Converter Accuracy: Pitfalls and Verification

Common Pitfalls

  • Reading remainders in the wrong order. Always read from the last remainder up to the first.
  • Mixing number systems. Each number system has its own place values, so treating 101 as one hundred and one instead of five is the most frequent input mistake.
  • Dropping leading zeros when a fixed width such as 8 bits is required.

Verification Strategies

The quickest check is a reverse conversion: turn your binary answer back into decimal by adding the weights of every 1. If you land on the original number, the conversion is correct. You can also double-check a result with a second decimal/binary converter, especially for large values.

Online tools have trade-offs worth knowing:

  • Speed: results are instant.
  • Accuracy: no arithmetic slips on long values.
  • Convenience: works on any device.
  • Internet dependency: you need a connection.
  • Input errors: a mistyped digit gives a wrong answer that looks perfectly valid.

Why Decimal to Binary Conversion Matters in Computers

Hardware can only store binary, so every decimal value has to be converted before a machine can use it. Every file, image and network packet is stored as binary digits, so number conversion shows up across computing work. In hardware, a bit maps to the on/off state of billions of transistors. In software, algorithms and low-level code manipulate those values directly.

Why Decimal to Binary Conversion Matters in Computers
WidthMaximum value (unsigned integer)Typical use
8-bit255Color representation and image processing channels
16-bit65,535Data representation in audio samples and ports
32-bit4,294,967,295IPv4 addresses and subnet masks
64-bit18,446,744,073,709,551,615Programming with large counters and digital systems

The same conversion applies whenever you turn a decimal character code or a subnet octet into binary for ASCII text to binary encoding, network protocols and data storage. Developers who understand it can read a subnet mask, a permission flag or a color value at a glance, and even a simple loop can turn a decimal value into binary when no tool is open.

Scale showing the maximum unsigned value an 8-bit, 16-bit, 32-bit and 64-bit binary number can hold
Each common bit width has a fixed ceiling for the decimal values it can store.