Binary Converter & Number Translator

Fast, accurate online binary converter. Convert between binary, decimal, hexadecimal, and octal with signed two's complement (-4, -7), IPv4 subnet mask to binary, and step-by-step calculation proofs.

Decimal format: 0-9
Popular Numbers:
Negative (Two's Comp):
Binary Code:
Converted Value

All Base Representations

Binary (Base 2)
-
4-bit nibbles: -
Decimal (Base 10)
-
Standard magnitude
Hexadecimal (Base 16)
-
Prefix: 0x-
Octal (Base 8)
-
ASCII: -

Signed Two's Complement Formats

Essential for negative numbers in binary (-4, -7, etc.)
8-bit Signed (Range: -128 to 127):
-
16-bit Signed (-32,768 to 32,767):
-
32-bit Signed (Standard int):
-
Hex Two's Complement:
-

Step-by-Step Conversion Walkthrough

Division by 2 Proof

Comprehensive Guide to Binary Conversion

Binary is the bedrock of modern electronic computing, digital microprocessors, and network telecommunications. While humans calculate in decimal (base 10) because we evolved with ten fingers, computers communicate using silicon transistors that exist in two physical states: electrical voltage on (represented by 1) or electrical voltage off (represented by 0).

Whether you are developing software, analyzing network packets, configuring routing subnets, or debugging low-level memory, converting between binary, decimal, octal, and hexadecimal is an essential daily skill.

The Four Essential Number Systems

  • Binary (Base 2): Uses only two symbols: 0 and 1. Each place value represents an ascending power of 2 ($2^0, 2^1, 2^2, 2^3 \dots$).
  • Octal (Base 8): Uses digits 0 through 7. Popular in Unix file permission strings (e.g. chmod 755). Each octal digit corresponds to exactly 3 binary bits.
  • Decimal (Base 10): The universal human counting system using digits 0 through 9.
  • Hexadecimal (Base 16): Uses digits 0–9 and letters A–F (where A=10, B=11, C=12, D=13, E=14, F=15). Each hex digit represents exactly 4 binary bits (one nibble).

Why Manual Conversion Causes Errors

Performing long division by 2 or positional power additions by hand is time-consuming and susceptible to simple arithmetic slips—especially when managing sign bits, two's complement carries, or 32-bit subnet octets.

Our free online binary converter eliminates human error by delivering instant, verified two-way conversions alongside full step-by-step mathematical proofs.

How to Convert Between Decimal and Binary Manually

Understand the two core mathematical algorithms used in computer science textbooks and technical exams:

Decimal to Binary (Successive Division by 2)

  1. Divide the integer decimal number by 2.
  2. Write down the integer quotient and the remainder (0 or 1).
  3. Repeat the division with the quotient until the quotient reaches 0.
  4. Read all remainders in reverse order (from bottom to top).
Worked Example: Decimal 21 to Binary
Division Quotient Remainder
21 ÷ 2101 (LSB)
10 ÷ 250
5 ÷ 221
2 ÷ 210
1 ÷ 201 (MSB)
Result (read bottom-to-top): 10101₂

Binary to Decimal (Positional Weighting)

  1. Write down the binary digits from right to left.
  2. Assign an ascending power of 2 starting at $2^0 = 1$ for the rightmost bit.
  3. Multiply each binary bit by its corresponding power of 2.
  4. Sum all resulting products to get the decimal equivalent.
Worked Example: Binary 10101₂ to Decimal
(1 × 2⁴) + (0 × 2³) + (1 × 2²) + (0 × 2¹) + (1 × 2⁰)
= 16 + 0 + 4 + 0 + 1
= 21₁₀

Negative Numbers in Binary: Two's Complement Explained

How do digital systems represent negative values like -4 in binary or -7 in binary? In digital hardware, circuits cannot store a literal minus sign ("-"). Instead, computers universally rely on two's complement notation.

-4 in Binary (8-bit Step-by-Step)

Keyword Target
  1. Start with +4 in 8-bit binary:
    0000 0100
  2. Invert every bit (One's Complement):
    1111 1011
  3. Add 1 to the inverted result:
    1111 1011 + 1 = 1111 1100
Therefore, in 8-bit two's complement, -4 in binary is 11111100. In 16-bit it is 11111111 11111100, and in hex it is 0xFC.

-7 in Binary (8-bit Step-by-Step)

Keyword Target
  1. Start with +7 in 8-bit binary:
    0000 0111
  2. Invert every bit (One's Complement):
    1111 1000
  3. Add 1 to the inverted result:
    1111 1000 + 1 = 1111 1001
Therefore, in 8-bit two's complement, -7 in binary is 11111001. In 16-bit it is 11111111 11111001, and in hex it is 0xF9.
Why Bit-Width Matters: The same bit pattern 11111100 represents -4 in 8-bit signed two's complement, but represents 252 in unsigned binary! Always verify the bit-width (8-bit, 16-bit, 32-bit, or 64-bit) when writing firmware or decoding network packets.

Subnet to Binary: IPv4 Subnet Masks in Networking

In IPv4 computer networking, every IP address consists of 32 bits divided into four 8-bit octets. A subnet mask tells routers which bits identify the network and which bits identify individual hosts.

CIDR Prefix Dotted Decimal Subnet Mask 32-Bit Binary Octets Usable IP Hosts
/30 255.255.255.252 11111111.11111111.11111111.11111100 2
/29 255.255.255.248 11111111.11111111.11111111.11111000 6
/28 255.255.255.240 11111111.11111111.11111111.11110000 14
/26 255.255.255.192 11111111.11111111.11111111.11000000 62
/24 255.255.255.0 11111111.11111111.11111111.00000000 254
/16 255.255.0.0 11111111.11111111.00000000.00000000 65,534

Binary Code Translator: Reference Table (0 to 32)

Quick conversion lookup chart for Decimal, 8-Bit Binary, Hexadecimal, and Octal.

Decimal Binary (8-bit) Hexadecimal Octal
0 00000000 0x0 0
1 00000001 0x1 1
2 00000010 0x2 2
3 00000011 0x3 3
4 00000100 0x4 4
5 00000101 0x5 5
6 00000110 0x6 6
7 00000111 0x7 7
8 00001000 0x8 10
9 00001001 0x9 11
10 00001010 0xA 12
11 00001011 0xB 13
12 00001100 0xC 14
13 00001101 0xD 15
14 00001110 0xE 16
15 00001111 0xF 17
16 00010000 0x10 20
17 00010001 0x11 21
18 00010010 0x12 22
19 00010011 0x13 23
20 00010100 0x14 24
21 00010101 0x15 25
22 00010110 0x16 26
23 00010111 0x17 27
24 00011000 0x18 30
25 00011001 0x19 31
26 00011010 0x1A 32
27 00011011 0x1B 33
28 00011100 0x1C 34
29 00011101 0x1D 35
30 00011110 0x1E 36
31 00011111 0x1F 37
32 00100000 0x20 40

Frequently Asked Questions (FAQ)

In modern computing systems using 8-bit signed two's complement representation, -4 in binary is 11111100. In a 16-bit architecture, it is 1111111111111100, and in 32-bit it is 11111111111111111111111111111100. To calculate it: take positive 4 (00000100), invert all bits to obtain 11111011 (one's complement), and add 1 to get 11111100.

Was this tool helpful?

Comments

Loading comments...

Check Out Other Popular Tools