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

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

BitsSigned RangeUnsigned Range
8-128 to 1270 to 255
16-32,768 to 32,7670 to 65,535
32-2,147,483,648 to 2,147,483,6470 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:

DecimalBinaryHexOctal
000000000000
100000001011
200000010022
300000011033
400000100044
500000101055
600000110066
700000111077
8000010000810
9000010010911
10000010100A12
11000010110B13
12000011000C14
13000011010D15
14000011100E16
15000011110F17
16000100001020
17000100011121
18000100101222
19000100111323
20000101001424
21000101011525
22000101101626
23000101111727
24000110001830
25000110011931
26000110101A32
27000110111B33
28000111001C34
29000111011D35
30000111101E36
31000111111F37

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.

Related Tools