Base-2 (Binary) Number System
The fundamental language of computers - understanding binary as the foundation of all digital systems and cybersecurity applications.
Learning Objectives
- Understand binary as the fundamental computer number system
- Learn binary place values and conversion methods
- Explore binary arithmetic and bitwise operations
- Apply binary concepts to cybersecurity scenarios
Binary Fundamentals
What is Binary?
Binary uses only two digits: 0 and 1
These represent electronic switch states:
Binary Units
Unit | Value | Description |
---|---|---|
Bit | 1 binary digit | Smallest unit (0 or 1) |
Byte | 8 bits | Can represent 256 different values (0-255) |
Binary Place Values
Each position represents a power of 2. Here's an example with 11010110₂:
2⁷ | 2⁶ | 2⁵ | 2⁴ | 2³ | 2² | 2¹ | 2⁰ |
---|---|---|---|---|---|---|---|
128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1 | 1 | 0 | 1 | 0 | 1 | 1 | 0 |
Calculation: 11010110₂ = 128 + 64 + 16 + 4 + 2 = 214₁₀
Number System Conversions
Common Number Systems
- Binary (Base 2): 0, 1
- Octal (Base 8): 0-7
- Decimal (Base 10): 0-9
- Hexadecimal (Base 16): 0-9, A-F
Powers of 2 (Networking)
- 21 = 2
- 22 = 4
- 23 = 8
- 24 = 16
- 28 = 256
Base Conversion Reference
Decimal | Binary | Octal | Hexadecimal |
---|---|---|---|
0 | 0000 | 0 | 0 |
1 | 0001 | 1 | 1 |
2 | 0010 | 2 | 2 |
3 | 0011 | 3 | 3 |
4 | 0100 | 4 | 4 |
5 | 0101 | 5 | 5 |
6 | 0110 | 6 | 6 |
7 | 0111 | 7 | 7 |
8 | 1000 | 10 | 8 |
9 | 1001 | 11 | 9 |
10 | 1010 | 12 | A |
11 | 1011 | 13 | B |
12 | 1100 | 14 | C |
13 | 1101 | 15 | D |
14 | 1110 | 16 | E |
15 | 1111 | 17 | F |
255 | 11111111 | 377 | FF |
Binary to Decimal
Method 1: Place Value Addition
Example: Convert 1011₂ to decimal
Step | Calculation |
---|---|
1 | 1011₂ = (1×2³) + (0×2²) + (1×2¹) + (1×2⁰) |
2 | = (1×8) + (0×4) + (1×2) + (1×1) |
3 | = 8 + 0 + 2 + 1 = 11₁₀ |
Method 2: Doubling Method
Example: Convert 1011₂ to decimal
- Start with leftmost bit: 1
- Double and add next: (1×2) + 0 = 2
- Double and add next: (2×2) + 1 = 5
- Double and add next: (5×2) + 1 = 11
Decimal to Binary
Division by 2 Method
Example: Convert 13₁₀ to binary
Division | Quotient | Remainder |
---|---|---|
13 ÷ 2 | 6 | 1 |
6 ÷ 2 | 3 | 0 |
3 ÷ 2 | 1 | 1 |
1 ÷ 2 | 0 | 1 |
Read remainders upward: 1101₂ |
Binary Addition Rules
A | B | Sum | Carry |
---|---|---|---|
0 | 0 | 0 | 0 |
0 | 1 | 1 | 0 |
1 | 0 | 1 | 0 |
1 | 1 | 0 | 1 |
Note: When both bits are 1, the result is 0 with a carry of 1 to the next position.
Bitwise Operations
AND Operation (&)
1010 |
1100 & |
1000 |
Result is 1 only when both bits are 1
OR Operation (|)
1010 |
1100 | |
1110 |
Result is 1 when either bit is 1
Cybersecurity Applications
IP Address Representation
IPv4 addresses are 32-bit binary numbers divided into 4 octets:
Decimal | Binary |
---|---|
192 | 11000000 |
168 | 10101000 |
1 | 00000001 |
1 | 00000001 |
192.168.1.1 = 11000000.10101000.00000001.00000001
File Permissions
Unix file permissions use 3-bit binary groups:
Octal | Binary | Permissions |
---|---|---|
7 | 111 | rwx (full access) |
6 | 110 | rw- (read/write) |
4 | 100 | r-- (read only) |
0 | 000 | --- (no access) |
Network Subnetting
Subnet masks use binary to define network boundaries:
/24 Network:
255.255.255.0
11111111.11111111.11111111.00000000
/16 Network:
255.255.0.0
11111111.11111111.00000000.00000000
1s = Network portion
0s = Host portion
Binary Converter
Quick Reference
Base: | 2 |
Digits: | 0, 1 |
Place Values: | Powers of 2 (1, 2, 4, 8, 16...) |
8 bits: | 1 byte (256 possible values) |
Common Usage: | Computer systems, digital logic |