Decimal to Binary Converter
This decimal to binary converter transforms base-10 numbers into base-2 binary representation using the repeated division method. Enter any decimal number to see its binary equivalent with a step-by-step breakdown, plus octal and hexadecimal conversions. Supports 8-bit, 16-bit, and 32-bit fixed-width formats and two's complement for negative numbers.
Decimal to Binary Converter
Convert between decimal and binary number systems with step-by-step division
Frequently Asked Questions
How do you convert decimal to binary?
To convert a decimal number to binary, repeatedly divide the number by 2 and record the remainder at each step. Continue until the quotient reaches 0. Then read the remainders from bottom to top (last to first) to get the binary number. For example, to convert 13: 13/2=6 R1, 6/2=3 R0, 3/2=1 R1, 1/2=0 R1. Reading bottom to top gives 1101.
What is binary?
Binary is a base-2 number system that uses only two digits: 0 and 1. Each digit position represents a power of 2, just as each position in decimal (base-10) represents a power of 10. Binary is the native language of digital computers because electronic circuits have two states: on (1) and off (0). All data in a computer — text, images, audio, video — is ultimately represented as binary.
What is two's complement?
Two's complement is the standard method computers use to represent negative integers in binary. To find the two's complement of a number: (1) write the positive value in binary, (2) invert all bits (flip 0s to 1s and 1s to 0s), (3) add 1 to the result. For example, -5 in 8-bit two's complement: start with 00000101, invert to 11111010, add 1 to get 11111011. The most significant bit acts as the sign bit (0 = positive, 1 = negative).
What is the range of an 8-bit binary number?
For an unsigned 8-bit binary number, the range is 0 to 255 (00000000 to 11111111). For a signed 8-bit number using two's complement, the range is -128 to 127 (10000000 to 01111111). The maximum unsigned value is 2^8 - 1 = 255, while the signed range uses one bit for the sign, giving -2^7 to 2^7 - 1.
How do you represent negative numbers in binary?
Modern computers use two's complement to represent negative numbers. The most significant bit (leftmost) is the sign bit: 0 for positive, 1 for negative. To negate a number, invert all bits and add 1. For example, -1 in 8-bit binary is 11111111, -128 is 10000000, and -42 is 11010110. This system allows addition and subtraction to use the same hardware circuits.
Why do computers use binary?
Computers use binary because digital electronic circuits have two stable states: high voltage (1) and low voltage (0). This two-state system is extremely reliable, fast, and easy to implement with transistors. While humans find decimal (base-10) intuitive because we have 10 fingers, computers work naturally with binary (base-2). Higher bases like octal (8) and hexadecimal (16) are used as shorthand since they map cleanly to groups of binary bits.
What is the difference between 8-bit, 16-bit, and 32-bit?
The bit width determines how many binary digits are used to represent a number. 8-bit (1 byte) can represent 256 values (0-255 unsigned or -128 to 127 signed). 16-bit (2 bytes) represents 65,536 values (0-65535 unsigned). 32-bit (4 bytes) represents over 4 billion values (0 to 4,294,967,295 unsigned). Larger bit widths allow bigger numbers but use more memory.
How do I convert decimal to binary in Python or JavaScript?
In Python, use bin(42) to get '0b101010', or format(42, 'b') to get '101010' without the prefix. In JavaScript, use (42).toString(2) to get '101010'. To convert back: Python uses int('101010', 2) = 42, JavaScript uses parseInt('101010', 2) = 42. Both languages support binary literals with the 0b prefix: 0b101010 equals 42.
What is the binary of common decimal numbers?
Common conversions: 0 = 0, 1 = 1, 2 = 10, 5 = 101, 10 = 1010, 16 = 10000, 32 = 100000, 42 = 101010, 64 = 1000000, 100 = 1100100, 128 = 10000000, 255 = 11111111, 256 = 100000000, 1000 = 1111101000, 1024 = 10000000000. Powers of 2 always have exactly one '1' bit followed by zeros.
How does binary relate to hexadecimal?
Hexadecimal (base-16) is a compact representation of binary. Each hex digit maps to exactly 4 binary bits: 0=0000, 1=0001, ..., 9=1001, A=1010, B=1011, C=1100, D=1101, E=1110, F=1111. So the hex value FF equals binary 11111111 (decimal 255), and 0x2A equals binary 00101010 (decimal 42). This 4-bit alignment makes hex ideal for representing byte values.
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
- 42 ÷ 2 = 21, remainder 0
- 21 ÷ 2 = 10, remainder 1
- 10 ÷ 2 = 5, remainder 0
- 5 ÷ 2 = 2, remainder 1
- 2 ÷ 2 = 1, remainder 0
- 1 ÷ 2 = 0, remainder 1
Read remainders bottom to top: 101010
Therefore, decimal 42 = binary 101010.
Example: Convert 255 to Binary
Decimal input: 255
- 255 ÷ 2 = 127, remainder 1
- 127 ÷ 2 = 63, remainder 1
- 63 ÷ 2 = 31, remainder 1
- 31 ÷ 2 = 15, remainder 1
- 15 ÷ 2 = 7, remainder 1
- 7 ÷ 2 = 3, remainder 1
- 3 ÷ 2 = 1, remainder 1
- 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:
- Start with the binary of 5: 00000101
- Invert all bits: 11111010
- 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 (2^30).
- Cryptography — Encryption algorithms, hash functions, and key generation operate on binary data. Understanding binary representation is fundamental to cryptographic analysis.
- Education — Learning decimal-to-binary conversion builds foundational understanding of how computers work, making it a core topic in computer science curricula.
Related Converters
- Binary to Decimal Converter — Convert binary numbers to decimal with step-by-step positional notation breakdown
- Hex to Binary Converter — Convert hexadecimal numbers to binary with 4-bit group visualization
- Binary Translator — Translate between binary code and text (ASCII/Unicode)
- Hex to Decimal Converter — Convert hexadecimal values to decimal numbers
- Hex to Text Converter — Decode hexadecimal byte values to readable text