What Is the Decimal to Binary Converter?
This tool converts a number written in our everyday base-10 (decimal) system into base-2 (binary), the language computers use internally. Binary uses only two digits, 0 and 1, where each position represents a power of two. The converter is universal — it works the same in every country and for any non-negative whole number.
How to Use It
Enter a non-negative whole decimal number (for example 156) and submit. The calculator returns the equivalent binary string and how many bits (binary digits) it occupies. Negative numbers are treated as 0, and decimals are truncated to a whole number.
The Formula Explained
The classic method is repeated division by 2. Divide the number by 2 and record the remainder (0 or 1). Replace the number with the quotient and repeat until the quotient is 0. Reading the collected remainders from bottom to top (last to first) gives the binary representation.
$$\text{Binary} = \sum_{i=0}^{k-1} b_i \cdot 2^{i}, \quad b_i = \left\lfloor \frac{\text{Decimal}}{2^{i}} \right\rfloor \bmod 2$$Worked Example
Convert 156: \(156 \div 2 = 78\ r0\), \(78 \div 2 = 39\ r0\), \(39 \div 2 = 19\ r1\), \(19 \div 2 = 9\ r1\), \(9 \div 2 = 4\ r1\), \(4 \div 2 = 2\ r0\), \(2 \div 2 = 1\ r0\), \(1 \div 2 = 0\ r1\). Remainders bottom-to-top: 10011100. So 156 in decimal equals 10011100 in binary (8 bits).
Powers of Two and Common Decimal-to-Binary Values
Every binary digit (bit) position stands for a power of two. Position 0 is the rightmost bit. A binary number is the sum of the powers of two wherever a 1 appears.
| Power | Decimal value |
|---|---|
| \(2^0\) | 1 |
| \(2^1\) | 2 |
| \(2^2\) | 4 |
| \(2^3\) | 8 |
| \(2^4\) | 16 |
| \(2^5\) | 32 |
| \(2^6\) | 64 |
| \(2^7\) | 128 |
| \(2^8\) | 256 |
| \(2^9\) | 512 |
| \(2^{10}\) | 1024 |
| \(2^{11}\) | 2048 |
| \(2^{12}\) | 4096 |
| \(2^{13}\) | 8192 |
| \(2^{14}\) | 16384 |
| \(2^{15}\) | 32768 |
| \(2^{16}\) | 65536 |
Decimal 0-16 in Binary (with Hexadecimal)
| Decimal | Binary | Hex |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 1 | 1 |
| 2 | 10 | 2 |
| 3 | 11 | 3 |
| 4 | 100 | 4 |
| 5 | 101 | 5 |
| 6 | 110 | 6 |
| 7 | 111 | 7 |
| 8 | 1000 | 8 |
| 9 | 1001 | 9 |
| 10 | 1010 | A |
| 11 | 1011 | B |
| 12 | 1100 | C |
| 13 | 1101 | D |
| 14 | 1110 | E |
| 15 | 1111 | F |
| 16 | 10000 | 10 |
Common Boundaries
| Decimal | Binary | Note |
|---|---|---|
| 255 | 11111111 | \(2^8 - 1\), largest unsigned 8-bit value |
| 256 | 100000000 | \(2^8\), first value needing 9 bits |
| 1023 | 1111111111 | \(2^{10} - 1\), largest unsigned 10-bit value |
| 1024 | 10000000000 | \(2^{10}\), first value needing 11 bits |
| 65535 | 1111111111111111 | \(2^{16} - 1\), largest unsigned 16-bit value |
Pattern: \(2^n - 1\) is always n ones in a row, and \(2^n\) is a 1 followed by n zeros.
Interpreting the Binary Result and Bit Count
The bit count is the number of binary digits needed to write the number, which is the minimum storage width for it as an unsigned integer. For a positive integer \(n\):
$$\text{bits} = \lfloor \log_2 n \rfloor + 1$$
Zero is conventionally written with a single bit (0).
Example: for \(n = 1000\), \(\log_2 1000 \approx 9.966\), so \(\lfloor 9.966 \rfloor + 1 = 10\) bits. Check: \(1000 = 512 + 256 + 128 + 64 + 32 + 8\), which is 1111101000 in binary, and that has 10 digits.
How Many Values Fit in n Bits
n bits can represent \(2^n\) distinct values. For unsigned integers these run from 0 to \(2^n - 1\).
| Width | Distinct values | Max unsigned value |
|---|---|---|
| 8-bit (1 byte) | \(2^8 = 256\) | 255 |
| 16-bit (2 bytes) | \(2^{16} = 65{,}536\) | 65,535 |
| 32-bit (4 bytes) | \(2^{32} = 4{,}294{,}967{,}296\) | 4,294,967,295 |
| 64-bit (8 bytes) | \(2^{64}\) | 18,446,744,073,709,551,615 |
Bytes and Hexadecimal
- One byte is 8 bits, so the number of bytes needed is the bit count divided by 8, rounded up. A 10-bit number needs 2 bytes in practice.
- Each hexadecimal digit corresponds to exactly 4 bits (a nibble). To convert, pad the binary number with leading zeros to a multiple of 4 and group from the right. For example, 11111111 becomes 1111 1111, which is FF.
- Signed values stored in two's complement use one of the bits for the sign. An 8-bit signed integer covers -128 to 127, not 0 to 255.
Binary Terms Glossary
- Bit
- A binary digit, either 0 or 1. It is the smallest unit of digital information.
- Byte
- A group of 8 bits. It can represent 256 distinct values (0-255 unsigned).
- Nibble
- A group of 4 bits, or half a byte. It maps to exactly one hexadecimal digit (0-F).
- Base-2 (radix)
- The radix is the base of a number system, the number of distinct digits it uses. Binary is base-2 and uses only 0 and 1, with each position worth a power of 2. Decimal is base-10.
- Most significant bit (MSB)
- The leftmost bit of a binary number, the one with the highest place value. In an unsigned 8-bit number it is worth 128.
- Least significant bit (LSB)
- The rightmost bit, worth \(2^0 = 1\). It decides whether the number is odd (1) or even (0).
- Two's complement
- The most common way computers store signed integers. A negative number is formed by inverting all bits of its positive value and adding 1. In n bits it covers \(-2^{n-1}\) to \(2^{n-1} - 1\), and the MSB acts as the sign bit.
- Unsigned integer
- A whole number with no sign, stored as plain binary. In n bits it ranges from 0 to \(2^n - 1\).
FAQ
What is 0 in binary? It is simply 0.
How many bits does a number need? The bit count equals the number of binary digits — for example 156 needs 8 bits.
Can I convert negative numbers? This converter handles non-negative integers; negative inputs are treated as 0. Real systems use two's complement for negatives.