About Decimal to Binary Converter
The Decimal to Binary Converter transforms base-10 decimal numbers into base-2 binary representation, the fundamental number system used by all digital computers. Every piece of data a computer processes — text, images, audio, video, and instructions — is ultimately stored and manipulated as sequences of binary digits (bits), where each bit is either 0 or 1.
This tool converts any non-negative integer to binary instantly and shows the step-by-step division method so you can follow the conversion process. It also displays the octal (base-8) and hexadecimal (base-16) equivalents, supports fixed-width formats (8-bit, 16-bit, 32-bit), and handles negative numbers using two's complement representation.
How to Convert Decimal to Binary
The standard method for converting a decimal integer to binary is the repeated division by 2 algorithm. You divide the number by 2 repeatedly, recording the remainder at each step, until the quotient reaches 0. The binary result is the sequence of remainders read from bottom to top (last remainder first).
Example: Convert 42 to Binary
Decimal input: 42
1. 42 ÷ 2 = 21, remainder 0
2. 21 ÷ 2 = 10, remainder 1
3. 10 ÷ 2 = 5, remainder 0
4. 5 ÷ 2 = 2, remainder 1
5. 2 ÷ 2 = 1, remainder 0
6. 1 ÷ 2 = 0, remainder 1
Read remainders bottom to top: 101010
Therefore, decimal 42 = binary 101010.
Example: Convert 255 to Binary
Decimal input: 255
1. 255 ÷ 2 = 127, remainder 1
2. 127 ÷ 2 = 63, remainder 1
3. 63 ÷ 2 = 31, remainder 1
4. 31 ÷ 2 = 15, remainder 1
5. 15 ÷ 2 = 7, remainder 1
6. 7 ÷ 2 = 3, remainder 1
7. 3 ÷ 2 = 1, remainder 1
8. 1 ÷ 2 = 0, remainder 1
Read remainders bottom to top: 11111111
Decimal 255 = binary 11111111 (8 bits, all ones). This is the maximum value of a single unsigned byte.
General Formula:
Repeat: quotient = floor(N / 2), remainder = N mod 2, then N = quotient, until N = 0.
The binary number is the remainders read in reverse order (bottom to top).
Two's Complement Explained
Two's complement is the standard method used by computers to represent signed integers (positive and negative numbers). The most significant bit (MSB) serves as the sign bit: 0 for positive, 1 for negative. The remaining bits encode the magnitude.
How to Find Two's Complement
To represent -5 in 8-bit two's complement:
1. Start with the binary of 5: 00000101
2. Invert all bits: 11111010
3. Add 1: 11111011
Result: -5 in 8-bit two's complement = 11111011
Two's Complement Ranges
| Bits | Signed Range | Unsigned Range |
|---|---|---|
| 8 | -128 to 127 | 0 to 255 |
| 16 | -32,768 to 32,767 | 0 to 65,535 |
| 32 | -2,147,483,648 to 2,147,483,647 | 0 to 4,294,967,295 |
Two's complement has a key advantage: addition and subtraction work the same way for both positive and negative numbers, simplifying CPU hardware design. This is why virtually every modern processor uses it.
Common Conversions Table (0-31)
Here are the first 32 decimal values and their binary, hexadecimal, and octal equivalents:
| Decimal | Binary | Hex | Octal |
|---|---|---|---|
| 0 | 00000000 | 00 | 0 |
| 1 | 00000001 | 01 | 1 |
| 2 | 00000010 | 02 | 2 |
| 3 | 00000011 | 03 | 3 |
| 4 | 00000100 | 04 | 4 |
| 5 | 00000101 | 05 | 5 |
| 6 | 00000110 | 06 | 6 |
| 7 | 00000111 | 07 | 7 |
| 8 | 00001000 | 08 | 10 |
| 9 | 00001001 | 09 | 11 |
| 10 | 00001010 | 0A | 12 |
| 11 | 00001011 | 0B | 13 |
| 12 | 00001100 | 0C | 14 |
| 13 | 00001101 | 0D | 15 |
| 14 | 00001110 | 0E | 16 |
| 15 | 00001111 | 0F | 17 |
| 16 | 00010000 | 10 | 20 |
| 17 | 00010001 | 11 | 21 |
| 18 | 00010010 | 12 | 22 |
| 19 | 00010011 | 13 | 23 |
| 20 | 00010100 | 14 | 24 |
| 21 | 00010101 | 15 | 25 |
| 22 | 00010110 | 16 | 26 |
| 23 | 00010111 | 17 | 27 |
| 24 | 00011000 | 18 | 30 |
| 25 | 00011001 | 19 | 31 |
| 26 | 00011010 | 1A | 32 |
| 27 | 00011011 | 1B | 33 |
| 28 | 00011100 | 1C | 34 |
| 29 | 00011101 | 1D | 35 |
| 30 | 00011110 | 1E | 36 |
| 31 | 00011111 | 1F | 37 |
Applications
- Computing & Programming: Understanding how integers, characters, and data are stored in memory at the binary level. Bitwise operations, bit masking, and flag manipulation all require decimal-to-binary fluency.
- Networking: IP addresses and subnet masks are 32-bit binary numbers. Converting between decimal dotted-notation (e.g., 192.168.1.0) and binary is essential for subnetting and network design.
- Digital Electronics: Logic gates, flip-flops, registers, and bus architectures all operate on binary signals. Engineers routinely convert between decimal specifications and binary representations.
- Data Storage: File sizes, memory addresses, and disk sectors are measured in powers of 2. Understanding binary helps explain why a "1 GB" drive holds 1,073,741,824 bytes (230).
- Cryptography: Encryption algorithms, hash functions, and key generation operate on binary data. Understanding binary representation is fundamental to cryptographic analysis and our Vernam cipher tool.
- Education: Learning decimal-to-binary conversion builds foundational understanding of how computers work, making it a core topic in computer science curricula.