Binary to Decimal Converter
Convert binary numbers to decimal and decimal to binary instantly. Supports up to 64-bit numbers. This free converter gives instant, accurate results.
How Binary-to-Decimal Conversion Works
Binary (base-2) uses only the digits 0 and 1. Each position represents a power of 2, doubling from right to left. To convert binary to decimal, multiply each binary digit by its place value and sum the results.
Example: Convert 1011₂ to decimal
- Position 3 (leftmost): 1 × 2³ = 1 × 8 = 8
- Position 2: 0 × 2² = 0 × 4 = 0
- Position 1: 1 × 2¹ = 1 × 2 = 2
- Position 0 (rightmost): 1 × 2⁰ = 1 × 1 = 1
- Total: 8 + 0 + 2 + 1 = 11
For decimal to binary, repeatedly divide by 2 and record remainders from bottom to top. 11 ÷ 2 = 5 R1, 5 ÷ 2 = 2 R1, 2 ÷ 2 = 1 R0, 1 ÷ 2 = 0 R1 → reading remainders upward: 1011.
This positional notation system works the same way as decimal — just with a different base. In decimal (base-10), the number 347 means 3×10² + 4×10¹ + 7×10⁰ = 300 + 40 + 7. Binary uses the same principle with powers of 2 instead of powers of 10.
Binary Place Values Reference
The 8-bit byte is the fundamental unit of computer storage. Here's the complete place value table for 8-bit numbers (0–255):
| Bit position | Power of 2 | Decimal value |
|---|---|---|
| Bit 7 (MSB) | 2⁷ | 128 |
| Bit 6 | 2⁶ | 64 |
| Bit 5 | 2⁵ | 32 |
| Bit 4 | 2⁴ | 16 |
| Bit 3 | 2³ | 8 |
| Bit 2 | 2² | 4 |
| Bit 1 | 2¹ | 2 |
| Bit 0 (LSB) | 2⁰ | 1 |
A byte can represent any value from 0 (00000000₂) to 255 (11111111₂). Two bytes (16 bits) cover 0–65,535. Four bytes (32 bits) cover 0–4,294,967,295.
Extended Powers of 2 Table
For programmers and computer scientists, knowing powers of 2 up to 2⁶⁴ is essential for understanding memory addressing, data types, and system limits:
| Power | Decimal Value | Significance |
|---|---|---|
| 2⁰ | 1 | Smallest unit (1 bit) |
| 2⁸ | 256 | 1 byte range (0–255) |
| 2¹⁰ | 1,024 | 1 KiB (kibibyte) |
| 2¹⁶ | 65,536 | 16-bit range; TCP port limit |
| 2²⁰ | 1,048,576 | 1 MiB (mebibyte) |
| 2²⁴ | 16,777,216 | 24-bit color (16.7M colors) |
| 2³⁰ | 1,073,741,824 | 1 GiB (gibibyte) |
| 2³² | 4,294,967,296 | 32-bit address space; IPv4 max |
| 2⁴⁰ | 1,099,511,627,776 | 1 TiB (tebibyte) |
| 2⁶⁴ | 18,446,744,073,709,551,616 | 64-bit address space; modern CPUs |
Note the difference between binary prefixes (KiB, MiB, GiB — powers of 2) and SI prefixes (KB, MB, GB — powers of 10). 1 GB = 1,000,000,000 bytes; 1 GiB = 1,073,741,824 bytes. This ~7% difference explains why a "500 GB" hard drive shows as ~465 GiB in your OS (which typically uses binary units internally).
Common Binary Values in Computing
These binary values appear frequently in programming, networking, and system administration:
| Binary | Decimal | Hexadecimal | Context |
|---|---|---|---|
| 00000000 | 0 | 0x00 | NULL byte, black color channel |
| 00001010 | 10 | 0x0A | Line feed (LF) character — Unix newline |
| 00001101 | 13 | 0x0D | Carriage return (CR) — Windows newline part |
| 00100000 | 32 | 0x20 | Space character (ASCII) |
| 01000001 | 65 | 0x41 | ASCII 'A' |
| 01100001 | 97 | 0x61 | ASCII 'a' (differs from 'A' by bit 5) |
| 01111111 | 127 | 0x7F | Localhost IP (last octet); DEL character |
| 10000000 | 128 | 0x80 | Start of extended ASCII / sign bit |
| 11000000 | 192 | 0xC0 | Class C network prefix (192.x.x.x) |
| 11111111 | 255 | 0xFF | Broadcast; max byte; white in RGB |
Binary, Hexadecimal, and Octal Comparison
Programmers use different number bases depending on context. Here's how the same values appear in each system:
| Decimal | Binary | Hexadecimal | Octal | Use Case |
|---|---|---|---|---|
| 0 | 0000 | 0x0 | 0o0 | Zero / null |
| 7 | 0111 | 0x7 | 0o7 | Unix permission (rwx) |
| 10 | 1010 | 0xA | 0o12 | — |
| 15 | 1111 | 0xF | 0o17 | Max 4-bit (nibble) |
| 16 | 10000 | 0x10 | 0o20 | — |
| 127 | 1111111 | 0x7F | 0o177 | Max signed 8-bit |
| 255 | 11111111 | 0xFF | 0o377 | Max unsigned 8-bit |
| 511 | 111111111 | 0x1FF | 0o777 | Unix permission rwxrwxrwx |
| 1023 | 1111111111 | 0x3FF | 0o1777 | Max 10-bit (ADC) |
Hexadecimal is the most common shorthand for binary because each hex digit maps to exactly 4 binary bits — making conversion trivial. Octal maps 3 bits per digit and is primarily used for Unix file permissions (e.g., chmod 755 = 111 101 101 in binary = rwxr-xr-x).
Signed Binary Numbers (Two's Complement)
Computers represent negative numbers using two's complement — the standard defined by IEEE and used by virtually all modern processors. In an 8-bit two's complement system:
| Binary | Unsigned Decimal | Signed (Two's Complement) |
|---|---|---|
| 00000000 | 0 | 0 |
| 00000001 | 1 | +1 |
| 01111111 | 127 | +127 (max positive) |
| 10000000 | 128 | −128 (min negative) |
| 10000001 | 129 | −127 |
| 11111110 | 254 | −2 |
| 11111111 | 255 | −1 |
To negate a number in two's complement: invert all bits and add 1. For example, +5 = 00000101 → invert → 11111010 → add 1 → 11111011 = −5.
The ranges for common integer types:
| Type | Bits | Unsigned Range | Signed Range |
|---|---|---|---|
| byte / uint8 | 8 | 0 to 255 | −128 to +127 |
| short / int16 | 16 | 0 to 65,535 | −32,768 to +32,767 |
| int / int32 | 32 | 0 to 4,294,967,295 | −2,147,483,648 to +2,147,483,647 |
| long / int64 | 64 | 0 to 18.4 × 10¹⁸ | −9.2 × 10¹⁸ to +9.2 × 10¹⁸ |
Binary in Everyday Technology
Binary is the foundation of all modern computing because transistors have two stable states (on/off, 1/0). Key applications:
- File sizes: 1 kilobyte = 2¹⁰ = 1,024 bytes; 1 megabyte = 2²⁰ = 1,048,576 bytes; 1 gigabyte = 2³⁰ bytes
- Colors: RGB colors are three 8-bit values. #FF5733 in hex = (255, 87, 51) in decimal = (11111111, 01010111, 00110011) in binary
- ASCII encoding: The letter 'A' = decimal 65 = binary 01000001; 'a' = 97 = 01100001
- Unicode: Most text characters fit in 16-bit binary (0–65,535 range)
- IP addresses: IPv4 addresses are four 8-bit binary groups: 192.168.1.1 = 11000000.10101000.00000001.00000001
Understanding binary directly helps in programming (bitwise operations, flags), networking (IP/subnet calculations), and working with low-level hardware.
Binary Arithmetic: Addition and Subtraction
Binary arithmetic follows the same rules as decimal, but with only two digits. The addition table is:
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Example: 1011 + 0110
Working right to left: 1+0=1, 1+1=10 (write 0 carry 1), 0+1+1=10 (write 0 carry 1), 1+0+1=10 (write 0 carry 1). Result: 10001 (decimal: 11+6=17 ✓)
Subtraction in hardware is typically performed by adding the two's complement of the subtrahend. To compute A−B, the processor calculates A + (−B), where −B is the two's complement of B. This allows a single adder circuit to handle both addition and subtraction.
Bitwise Operations
Programming languages provide bitwise operators that manipulate individual bits. These are fundamental for low-level programming, embedded systems, and performance optimization:
| Operation | Symbol | Example (8-bit) | Result | Use Case |
|---|---|---|---|---|
| AND | & | 10110101 & 11110000 | 10110000 | Masking bits, extracting fields |
| OR | | | 10110101 | 00001111 | 10111111 | Setting bits, combining flags |
| XOR | ^ | 10110101 ^ 11111111 | 01001010 | Toggling bits, simple encryption |
| NOT | ~ | ~10110101 | 01001010 | Bit inversion |
| Left shift | << | 00000101 << 2 | 00010100 | Multiply by 2ⁿ |
| Right shift | >> | 00010100 >> 2 | 00000101 | Divide by 2ⁿ |
Bit shifting is significantly faster than multiplication/division in many processors. x << 1 is equivalent to x × 2, and x >> 1 is equivalent to x ÷ 2 (integer division). Game engines and embedded firmware use these operations extensively for performance.
Binary-Coded Decimal (BCD)
Binary-Coded Decimal represents each decimal digit using its own 4-bit binary pattern. Unlike pure binary, BCD preserves the decimal structure:
| Decimal | Pure Binary | BCD |
|---|---|---|
| 0 | 0000 | 0000 |
| 5 | 0101 | 0101 |
| 9 | 1001 | 1001 |
| 10 | 1010 | 0001 0000 |
| 42 | 101010 | 0100 0010 |
| 99 | 1100011 | 1001 1001 |
| 255 | 11111111 | 0010 0101 0101 |
BCD is less space-efficient than pure binary (10 of the 16 possible 4-bit combinations are used), but it simplifies decimal display — each nibble maps directly to a displayed digit. BCD is used in digital clocks, calculators, financial systems (where exact decimal representation matters), and older mainframe databases (COBOL, IBM EBCDIC).
Floating-Point Binary (IEEE 754)
Decimal numbers with fractional parts (like 3.14) are stored in binary using the IEEE 754 standard. A 32-bit (single-precision) float has three parts:
| Field | Bits | Purpose |
|---|---|---|
| Sign | 1 | 0 = positive, 1 = negative |
| Exponent | 8 | Biased exponent (bias = 127) |
| Mantissa (significand) | 23 | Fractional part (implicit leading 1) |
Example: The decimal number −6.5 in IEEE 754 single-precision:
- Sign = 1 (negative)
- 6.5 in binary = 110.1₂ = 1.101 × 2² (normalized)
- Exponent = 2 + 127 (bias) = 129 = 10000001₂
- Mantissa = 10100000000000000000000 (23 bits, implicit leading 1 omitted)
- Full representation: 1 10000001 10100000000000000000000
This is why 0.1 + 0.2 ≠ 0.3 in most programming languages — the decimal fraction 0.1 has an infinite repeating representation in binary (like 1/3 in decimal = 0.333…), so it must be rounded, introducing tiny errors. For financial calculations, use decimal arithmetic libraries (Python's decimal module, Java's BigDecimal) instead of floating-point.
Character Encoding: From ASCII to UTF-8
Text is stored as binary numbers mapped to characters. The evolution of character encoding reflects the global expansion of computing:
| Encoding | Year | Bits per Character | Characters Supported | Notes |
|---|---|---|---|---|
| ASCII | 1963 | 7 (stored in 8) | 128 | English letters, digits, punctuation |
| Extended ASCII (ISO 8859-1) | 1987 | 8 | 256 | Western European characters (é, ñ, ü) |
| UTF-8 | 1993 | 8–32 (variable) | 1,112,064 | Backward-compatible with ASCII; web standard |
| UTF-16 | 1996 | 16–32 (variable) | 1,112,064 | Used in Java, Windows, JavaScript internal |
| UTF-32 | 2000 | 32 (fixed) | 1,112,064 | Fixed width; wastes space for Latin text |
UTF-8 encodes ASCII characters in a single byte (identical to plain ASCII), European characters in 2 bytes, CJK characters in 3 bytes, and emoji in 4 bytes. Over 98% of all web pages use UTF-8 encoding (per W3Techs, 2024).
Binary Logic Gates
Logic gates are the physical building blocks of all digital circuits. Each gate performs a simple binary operation on one or two input bits:
| Gate | Symbol | Truth Table (A,B → Output) | Description |
|---|---|---|---|
| AND | A·B | 0,0→0; 0,1→0; 1,0→0; 1,1→1 | Output is 1 only when both inputs are 1 |
| OR | A+B | 0,0→0; 0,1→1; 1,0→1; 1,1→1 | Output is 1 when at least one input is 1 |
| NOT | ¬A | 0→1; 1→0 | Inverts the input |
| NAND | ¬(A·B) | 0,0→1; 0,1→1; 1,0→1; 1,1→0 | AND followed by NOT — universal gate |
| XOR | A⊕B | 0,0→0; 0,1→1; 1,0→1; 1,1→0 | Output is 1 when inputs differ |
The NAND gate is called a universal gate because any other logic function can be built using only NAND gates. Modern CPUs contain billions of transistors arranged into NAND and NOR gates, which are then combined into adders, multiplexers, flip-flops, and all the other building blocks of a processor. The Apple M3 chip contains approximately 25 billion transistors — each one a microscopic binary switch that is either on (1) or off (0).
The XOR gate has a special property: it outputs 1 when the two inputs are different. This makes it the foundation of binary addition (the sum bit of a half adder), error detection (parity checks), and simple encryption (XOR cipher).
History of Binary: From Leibniz to Modern Computing
The binary number system has a rich intellectual history:
| Year | Person/Event | Contribution |
|---|---|---|
| ~300 BC | Pingala (Indian mathematician) | Used binary-like system to classify poetic meters |
| 1679 | Gottfried Leibniz | Formally described modern binary arithmetic; saw connections to Chinese I Ching |
| 1847 | George Boole | Published "The Mathematical Analysis of Logic" — Boolean algebra foundation |
| 1937 | Claude Shannon (MIT thesis) | Showed Boolean algebra could model electrical switching circuits |
| 1945 | John von Neumann | Proposed stored-program binary computer architecture (von Neumann architecture) |
| 1971 | Intel 4004 | First commercial microprocessor — 2,300 transistors, 4-bit binary |
| 2024 | Modern CPUs | Billions of transistors; 64-bit binary architecture standard |
Leibniz's insight that all numbers could be expressed using only 0 and 1 was purely mathematical — he never imagined electronic computers. Shannon's 1937 master's thesis connected Boolean (binary) logic to electrical relays, creating the theoretical foundation for all digital electronics. It has been called "possibly the most important master's thesis of the twentieth century."
Binary in Networking: IP Addresses and Subnet Masks
Understanding binary is essential for network administration. IPv4 addresses and subnet masks are 32-bit binary numbers:
| Description | Dotted Decimal | Binary |
|---|---|---|
| IP address | 192.168.1.100 | 11000000.10101000.00000001.01100100 |
| Subnet mask (/24) | 255.255.255.0 | 11111111.11111111.11111111.00000000 |
| Network address | 192.168.1.0 | 11000000.10101000.00000001.00000000 |
| Broadcast address | 192.168.1.255 | 11000000.10101000.00000001.11111111 |
The network address is calculated by ANDing the IP with the subnet mask. The broadcast address sets all host bits to 1. The number of usable host addresses = 2(32−prefix) − 2. For a /24 network: 2⁸ − 2 = 254 usable hosts.
Common subnet sizes:
| CIDR | Subnet Mask | Hosts | Typical Use |
|---|---|---|---|
| /32 | 255.255.255.255 | 1 | Single host route |
| /30 | 255.255.255.252 | 2 | Point-to-point link |
| /24 | 255.255.255.0 | 254 | Standard LAN |
| /16 | 255.255.0.0 | 65,534 | Large campus network |
| /8 | 255.0.0.0 | 16,777,214 | Class A allocation |
Frequently Asked Questions
How do I convert binary 1100 to decimal?
1100 in binary: 1×8 + 1×4 + 0×2 + 0×1 = 8 + 4 = 12. So binary 1100 = decimal 12.
What is 255 in binary?
255 in binary is 11111111 — all eight bits set to 1. This is the maximum value of a single byte and appears in networking (subnet mask 255.255.255.0) and color values (full red = 255, 0, 0).
How do I convert decimal 100 to binary?
Repeatedly divide by 2: 100÷2=50 R0, 50÷2=25 R0, 25÷2=12 R1, 12÷2=6 R0, 6÷2=3 R0, 3÷2=1 R1, 1÷2=0 R1. Reading remainders upward: 1100100₂. Verify: 64+32+4 = 100. ✓
What is the difference between binary and hexadecimal?
Binary uses base 2 (digits 0–1); hexadecimal uses base 16 (digits 0–9, A–F). Hex is compact shorthand for binary — each hex digit represents exactly 4 binary bits. For example, hex FF = binary 11111111 = decimal 255.
Why do computers use binary instead of decimal?
Electronic circuits are naturally binary: a transistor is either on (1) or off (0), and voltage is either high or low. Decimal would require 10 distinct voltage levels, which is difficult to implement reliably in hardware. Binary is noise-tolerant and maps perfectly to logical true/false operations.
What is two's complement?
Two's complement is the standard method for representing signed (positive and negative) integers in binary. To find the two's complement (negative) of a number: invert all bits and add 1. In an 8-bit system, +5 is 00000101, and −5 is 11111011. The leftmost bit is the sign bit: 0 = positive, 1 = negative. This system allows hardware to use the same adder circuit for both addition and subtraction.
How do I convert binary to hexadecimal?
Group the binary digits into sets of 4 from right to left, then convert each group. Example: 10110101₂ → 1011 0101 → B5₁₆. The groupings are: 0000=0, 0001=1, 0010=2, ..., 1001=9, 1010=A, 1011=B, 1100=C, 1101=D, 1110=E, 1111=F.
},{"@type":“Question”,“name”:“What is 255 in binary?”,“acceptedAnswer”:{"@type":“Answer”,“text”:“255 in binary is 11111111 — all eight bits set to 1. This is the maximum value of a single byte and appears in networking (subnet mask 255.255.255.0) and color values (full red = 255, 0, 0).”}},{"@type":“Question”,“name”:“Why do computers use binary instead of decimal?”,“acceptedAnswer”:{"@type":“Answer”,“text”:“Electronic circuits are naturally binary: a transistor is either on (1) or off (0). Decimal would require 10 distinct voltage levels, which is difficult to implement reliably in hardware.”}},{"@type":“Question”,“name”:“What is two’s complement?”,“acceptedAnswer”:{"@type":“Answer”,“text”:“Two’s complement represents negative numbers in binary. Invert all bits and add 1. It allows hardware to use the same adder circuit for both addition and subtraction.”}},{"@type":“Question”,“name”:“How do I convert binary to hexadecimal?”,“acceptedAnswer”:{"@type":“Answer”,“text”:“Group binary digits into sets of 4 from right to left, then convert each group: 0000=0, 0001=1, …, 1010=A, 1011=B, 1100=C, 1101=D, 1110=E, 1111=F.”}}]}