Binary Fundamentals: Why Base-2 Matters
Every computer at its core speaks a single language: binary. The processor in your laptop, the memory in your phone, the network card in your server — all of them manipulate electrical signals that are either on or off, high voltage or low voltage. These two states map naturally to the digits 1 and 0, creating the binary (base-2) number system.
While humans count in base-10 (decimal) because we have ten fingers, computers count in base-2 because transistors have two reliable states. Understanding the conversion between these two number systems is foundational knowledge for any developer, data scientist, or IT professional. You'll encounter binary in IP addresses, file permissions, color codes, network protocols, cryptography, and low-level programming.
In binary, each position represents a power of 2, just as each decimal position represents a power of 10. The rightmost digit is the ones place (2⁰ = 1), the next is the twos place (2¹ = 2), then fours (2² = 4), eights (2³ = 8), sixteens (2⁴ = 16), and so on. Each digit in a binary number is called a bit (binary digit).
Method 1: Positional Notation (The Standard Way)
The most intuitive method for converting binary to decimal is positional notation — multiply each bit by its corresponding power of 2 and sum the results.
Step-by-Step Example: Convert 101101 to Decimal
Write out each bit with its position number (starting from 0 on the right):
| Binary Digit | 1 | 0 | 1 | 1 | 0 | 1 |
|---|---|---|---|---|---|---|
| Position | 5 | 4 | 3 | 2 | 1 | 0 |
| Power of 2 | 2⁵=32 | 2⁴=16 | 2³=8 | 2²=4 | 2¹=2 | 2⁰=1 |
Multiply each bit by its power of 2:
(1 × 32) + (0 × 16) + (1 × 8) + (1 × 4) + (0 × 2) + (1 × 1)
= 32 + 0 + 8 + 4 + 0 + 1
= 45
Binary 101101 equals decimal 45. Every bit that is 1 contributes its power-of-2 value; bits that are 0 contribute nothing.
Practice: Convert 11001010 to Decimal
| Binary | 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|
| Position | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Value | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
= 128 + 64 + 0 + 0 + 8 + 0 + 2 + 0 = 202
Method 2: Doubling Method (Mental Math)
The doubling method is a faster approach that works well for mental calculation. Start from the leftmost bit and work right, doubling the running total and adding each new bit:
Example: Convert 101101
- Start with the leftmost bit: 1
- Double it: 1 × 2 = 2. Add next bit: 2 + 0 = 2
- Double it: 2 × 2 = 4. Add next bit: 4 + 1 = 5
- Double it: 5 × 2 = 10. Add next bit: 10 + 1 = 11
- Double it: 11 × 2 = 22. Add next bit: 22 + 0 = 22
- Double it: 22 × 2 = 44. Add next bit: 44 + 1 = 45
Same result: 45. This method is often faster for mental calculation because you only need to track one running total instead of computing multiple powers of 2.
Common Binary Values to Memorize
Some binary values appear so frequently in computing that memorizing them saves significant time:
| Binary | Decimal | Context |
|---|---|---|
| 00000001 | 1 | Lowest set bit |
| 00000010 | 2 | Bit 1, Unix read permission |
| 00000100 | 4 | Bit 2, Unix write permission |
| 00001000 | 8 | Bit 3, Unix execute permission |
| 00001111 | 15 | Nibble mask (all 4 lower bits set) |
| 01111111 | 127 | Max 8-bit signed value, max ASCII |
| 10000000 | 128 | Sign bit in 8-bit signed, high bit set |
| 11111111 | 255 | Max 8-bit unsigned value, subnet mask |
| 100000000 | 256 | 2⁸, byte boundary |
| 1111111111111111 | 65,535 | Max 16-bit unsigned (0xFFFF) |
The powers of 2 are worth memorizing entirely: 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536. These numbers appear everywhere in computing — from memory sizes to network masks to color channels.
Floating-Point Binary to Decimal
Not all binary numbers are whole numbers. Binary fractions work similarly to decimal fractions, but with negative powers of 2.
Binary Fractions Explained
In a binary fraction, the bits to the right of the "decimal point" (actually called the radix point in binary) represent negative powers of 2:
| Position | -1 | -2 | -3 | -4 |
|---|---|---|---|---|
| Power of 2 | 2⁻¹ = 0.5 | 2⁻² = 0.25 | 2⁻³ = 0.125 | 2⁻⁴ = 0.0625 |
Example: Convert 101.101 to Decimal
Integer part (101): 4 + 0 + 1 = 5
Fractional part (.101): 0.5 + 0 + 0.125 = 0.625
Total: 5.625
IEEE 754 Floating Point
Real computers store fractional numbers using the IEEE 754 standard, which encodes floating-point numbers in three parts:
- Sign bit (1 bit): 0 for positive, 1 for negative
- Exponent (8 or 11 bits): Encodes the scale (power of 2), biased by 127 (float) or 1023 (double)
- Mantissa/Significand (23 or 52 bits): Encodes the significant digits of the number
A single-precision float (32-bit) provides about 7 significant decimal digits of precision. A double-precision float (64-bit) provides about 15-16 significant digits. This is why 0.1 + 0.2 !== 0.3 in most programming languages — the binary representation of 0.1 is an infinitely repeating fraction (0.0001100110011...), just like 1/3 in decimal.
Binary in Programming: Practical Applications
Understanding binary-to-decimal conversion is directly useful in many programming scenarios:
Bitwise Operations
// Check if a number is even (rightmost bit is 0)
function isEven(n) { return (n & 1) === 0; }
// Check if the 3rd bit is set (value 4)
function hasFlag(flags) { return (flags & 4) !== 0; }
// Set multiple flags using binary OR
const READ = 4; // 100
const WRITE = 2; // 010
const EXEC = 1; // 001
const permissions = READ | WRITE; // 110 = 6
IP Addresses
IPv4 addresses are 32-bit binary numbers. The address 192.168.1.1 converts to binary as 11000000.10101000.00000001.00000001. Understanding this helps with subnet calculations. A /24 subnet mask (255.255.255.0) means the first 24 bits identify the network and the remaining 8 bits identify hosts on that network.
Color Codes
Hex color codes like #8B5CF6 are actually three 8-bit binary values packed together: 8B (139), 5C (92), F6 (246). Each component represents red, green, and blue as a decimal value from 0-255, stored as 8 binary bits. The alpha channel in RGBA adds a fourth 8-bit value for opacity.
File Permissions (Unix/Linux)
Unix file permissions use 3 bits per role (owner, group, others): read (4=100), write (2=010), execute (1=001). The permission chmod 755 means: owner gets 7 (rwx=111), group gets 5 (r-x=101), others get 5 (r-x=101). In binary: 111 101 101.
Quick Reference: Power of 2 Table
| n | 2ⁿ | n | 2ⁿ |
|---|---|---|---|
| 0 | 1 | 10 | 1,024 |
| 1 | 2 | 11 | 2,048 |
| 2 | 4 | 12 | 4,096 |
| 3 | 8 | 13 | 8,192 |
| 4 | 16 | 14 | 16,384 |
| 5 | 32 | 15 | 32,768 |
| 6 | 64 | 16 | 65,536 |
| 7 | 128 | 20 | 1,048,576 |
| 8 | 256 | 24 | 16,777,216 |
| 9 | 512 | 32 | 4,294,967,296 |
Convert Instantly with RiseTop
For quick conversions without manual calculation, RiseTop's Binary to Decimal Converter handles any binary number instantly — integers, fractions, and large numbers. Just paste your binary value and get the decimal result, plus step-by-step conversion breakdown so you can verify the math. It also supports the reverse conversion (decimal to binary) and shows both the positional and doubling methods.
Frequently Asked Questions
To convert binary to decimal, multiply each binary digit by 2 raised to the power of its position (starting from 0 on the right), then sum all the values. For example, binary 1011 = (1×2³) + (0×2²) + (1×2¹) + (1×2⁰) = 8 + 0 + 2 + 1 = 11 in decimal.
An 8-bit unsigned binary number can represent values from 0 to 255 (2⁸ - 1). The binary 11111111 equals 255 in decimal. If using two's complement for signed numbers, an 8-bit binary represents -128 to +127.
To convert decimal to binary, repeatedly divide the decimal number by 2 and record the remainders from bottom to top. For example, 25 ÷ 2 = 12 remainder 1, 12 ÷ 2 = 6 remainder 0, 6 ÷ 2 = 3 remainder 0, 3 ÷ 2 = 1 remainder 1, 1 ÷ 2 = 0 remainder 1. Reading remainders bottom-to-top: 11001.
Two's complement is a method for representing signed integers in binary. To negate a number, invert all bits and add 1. For example, 5 in 8-bit binary is 00000101. Its two's complement (negative 5) is 11111010 + 1 = 11111011. The leftmost bit indicates the sign: 0 for positive, 1 for negative.
Computers use binary because electronic circuits have two reliable states: on/off (voltage high/low), which naturally map to 1 and 0. Binary circuits are simpler, more reliable, and easier to manufacture than multi-state circuits. Transistors, the building blocks of processors, are essentially on/off switches.