Basic MathGuides

Understanding Number Systems: Binary and Hexadecimal Explained

Comprehensive Guide to Number Systems

1. Introduction to Number Systems

A number system is a way to represent numbers using a specific set of digits and a base (or radix). The base determines how many unique digits are used in the system.

Common Number Systems:

  • Decimal (Base-10): Uses digits 0-9
  • Binary (Base-2): Uses digits 0-1
  • Octal (Base-8): Uses digits 0-7
  • Hexadecimal (Base-16): Uses digits 0-9 and A-F

Number systems are fundamental to computing because computers operate using binary at their core, while humans typically work with decimal. Hexadecimal serves as a compact way to represent binary data.

2. Decimal (Base-10) System

The decimal system is our standard number system with 10 digits (0-9). Each position represents a power of 10.

Decimal Place Values

In the number 4,329:

  • 9 is in the ones place (100 = 1)
  • 2 is in the tens place (101 = 10)
  • 3 is in the hundreds place (102 = 100)
  • 4 is in the thousands place (103 = 1000)

Therefore: 4,329 = 4×1000 + 3×100 + 2×10 + 9×1 = 4,329

3. Binary (Base-2) System

The binary system uses only two digits: 0 and 1 (called bits). Each position represents a power of 2.

Binary Place Values

In the binary number 1011:

Position 23=8 22=4 21=2 20=1
Digit 1 0 1 1
Value 1×8=8 0×4=0 1×2=2 1×1=1

Therefore: 10112 = 8 + 0 + 2 + 1 = 1110

Why Binary is Important in Computing

Binary is used in computers because electronic components can easily represent two states:

  • On/Off
  • True/False
  • High voltage/Low voltage

Each binary digit (bit) is the smallest unit of data in computing. Eight bits make a byte, which can represent 28 = 256 different values.

Examples of Binary Numbers

Decimal Binary Calculation
0 0 0
1 1 1
2 10 1×21 + 0×20 = 2 + 0 = 2
5 101 1×22 + 0×21 + 1×20 = 4 + 0 + 1 = 5
10 1010 1×23 + 0×22 + 1×21 + 0×20 = 8 + 0 + 2 + 0 = 10
15 1111 1×23 + 1×22 + 1×21 + 1×20 = 8 + 4 + 2 + 1 = 15

4. Hexadecimal (Base-16) System

The hexadecimal (hex) system uses 16 digits: 0-9 and A-F, where:

  • A = 10
  • B = 11
  • C = 12
  • D = 13
  • E = 14
  • F = 15

Each position represents a power of 16.

Hexadecimal Place Values

In the hexadecimal number 2AF:

Position 162=256 161=16 160=1
Digit 2 A (10) F (15)
Value 2×256=512 10×16=160 15×1=15

Therefore: 2AF16 = 512 + 160 + 15 = 68710

Why Hexadecimal is Useful

Hexadecimal is widely used in computing because:

  • It's more compact than binary (one hex digit represents 4 binary digits)
  • It's used for memory addresses, color codes, and machine code representation
  • It's easier to read and write than long binary strings

Examples of Hexadecimal Numbers

Decimal Hexadecimal Calculation
10 A A×160 = 10×1 = 10
15 F F×160 = 15×1 = 15
16 10 1×161 + 0×160 = 16 + 0 = 16
42 2A 2×161 + A×160 = 32 + 10 = 42
255 FF F×161 + F×160 = 15×16 + 15×1 = 240 + 15 = 255
2023 7E7 7×162 + E×161 + 7×160 = 7×256 + 14×16 + 7×1 = 1792 + 224 + 7 = 2023

5. Number System Conversions

Decimal to Binary Conversion

Method: Division by 2

  1. Divide the decimal number by 2
  2. Write down the remainder (0 or 1)
  3. Divide the quotient by 2
  4. Repeat until the quotient becomes 0
  5. Read the remainders from bottom to top
Example: Convert 4210 to binary
42 ÷ 2 = 21 Remainder: 0
21 ÷ 2 = 10 Remainder: 1
10 ÷ 2 = 5 Remainder: 0
5 ÷ 2 = 2 Remainder: 1
2 ÷ 2 = 1 Remainder: 0
1 ÷ 2 = 0 Remainder: 1

Reading remainders from bottom to top: 4210 = 1010102

Binary to Decimal Conversion

Method: Positional Value

  1. Write down the powers of 2 for each position (from right to left, starting with 20)
  2. Multiply each binary digit by its corresponding power of 2
  3. Add all the results
Example: Convert 101102 to decimal
Position 24=16 23=8 22=4 21=2 20=1
Digit 1 0 1 1 0
Value 1×16=16 0×8=0 1×4=4 1×2=2 0×1=0

Total: 16 + 0 + 4 + 2 + 0 = 22, so 101102 = 2210

Decimal to Hexadecimal Conversion

Method: Division by 16

  1. Divide the decimal number by 16
  2. Convert the remainder to a hexadecimal digit (10-15 → A-F)
  3. Divide the quotient by 16
  4. Repeat until the quotient becomes 0
  5. Read the remainders from bottom to top
Example: Convert 42310 to hexadecimal
423 ÷ 16 = 26 Remainder: 7
26 ÷ 16 = 1 Remainder: 10 (A)
1 ÷ 16 = 0 Remainder: 1

Reading remainders from bottom to top: 42310 = 1A716

Hexadecimal to Decimal Conversion

Method: Positional Value

  1. Convert each hexadecimal digit to its decimal value (A-F → 10-15)
  2. Multiply each decimal value by its corresponding power of 16 (from right to left, starting with 160)
  3. Add all the results
Example: Convert 3F216 to decimal
Position 162=256 161=16 160=1
Hex Digit 3 F (15) 2
Value 3×256=768 15×16=240 2×1=2

Total: 768 + 240 + 2 = 1010, so 3F216 = 101010

Binary to Hexadecimal Conversion

Method: Group by 4 Bits

  1. Group binary digits into sets of 4, starting from the right
  2. Add leading zeros to the leftmost group if needed
  3. Convert each 4-bit group to its hexadecimal equivalent
Example: Convert 10110101102 to hexadecimal

Step 1: Group by 4 bits from the right: 10 1101 0110

Step 2: Add leading zeros to the leftmost group: 0010 1101 0110

Step 3: Convert each group:

Binary group 0010 1101 0110
Decimal value 2 13 6
Hex digit 2 D 6

Result: 10110101102 = 2D616

Hexadecimal to Binary Conversion

Method: Convert Each Digit

  1. Convert each hexadecimal digit to its 4-bit binary equivalent
  2. Concatenate all the binary groups
Example: Convert B3F16 to binary
Hex digit B (11) 3 F (15)
Binary (4 bits) 1011 0011 1111

Result: B3F16 = 1011001111112

Quick Reference: Binary to Hex Conversion Table

Binary Hex
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 7
Binary Hex
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F

6. Arithmetic in Different Number Systems

Binary Addition

Rules for Binary Addition

Addition Result Carry
0 + 0 0 0
0 + 1 1 0
1 + 0 1 0
1 + 1 0 1
1 + 1 + 1 1 1
Example: Add 10112 and 11012
    1 1 1 1     (Carries)
      1 0 1 1   (First number)
    + 1 1 0 1   (Second number)
    ---------
    1 1 0 0 0   (Result)
                

Working from right to left:

  1. 1 + 1 = 0, carry 1
  2. 1 + 0 + 1 (carry) = 0, carry 1
  3. 0 + 1 + 1 (carry) = 0, carry 1
  4. 1 + 1 + 1 (carry) = 1, carry 1
  5. 0 + 0 + 1 (carry) = 1

Result: 10112 + 11012 = 110002

Verify: 1110 + 1310 = 2410 = 110002

Binary Subtraction

Rules for Binary Subtraction

Subtraction Result Borrow
0 - 0 0 0
1 - 0 1 0
1 - 1 0 0
0 - 1 1 1 (borrow from next column)
Example: Subtract 1012 from 11012
        1 0     (Borrows)
    1 1 0 1     (First number)
  - 0 1 0 1     (Second number)
    -------
    1 0 0 0     (Result)
                

Working from right to left:

  1. 1 - 1 = 0
  2. 0 - 0 = 0
  3. 1 - 1 = 0
  4. 1 - 0 = 1

Result: 11012 - 1012 = 10002

Verify: 1310 - 510 = 810 = 10002

Hexadecimal Addition

For hexadecimal addition, you can:

  1. Convert hex digits to decimal
  2. Add them together
  3. If the sum is 16 or greater, keep the remainder and carry the 1
  4. Convert back to hex
Example: Add 2A716 and 39F16
      1 1       (Carries)
      2 A 7     (First number)
    + 3 9 F     (Second number)
    -------
      6 4 6     (Result)
                

Working from right to left:

  1. 7 + F = 7 + 15 = 22 = 16 + 6, write 6, carry 1
  2. A + 9 + 1 (carry) = 10 + 9 + 1 = 20 = 16 + 4, write 4, carry 1
  3. 2 + 3 + 1 (carry) = 6, write 6

Result: 2A716 + 39F16 = 64616

Verify: 67910 + 92710 = 160610 = 64616

7. Real-world Applications

Binary Applications

  • Digital Electronics: Binary is used in digital circuits where 0 represents "off" and 1 represents "on"
  • Computer Storage: All data in computers is stored as binary (bits and bytes)
  • Boolean Logic: Binary is used in logical operations (AND, OR, NOT, etc.)
  • Digital Images: In black and white images, 0 might represent black and 1 white

Hexadecimal Applications

  • Memory Addresses: Hexadecimal is used to represent memory locations in computing
  • Color Codes: Web colors in HTML/CSS use hex codes (#RRGGBB)
  • Assembly Language: Machine code is often written in hex
  • IPv6 Addresses: Internet Protocol v6 addresses use hexadecimal notation
  • MAC Addresses: Network interfaces use hex notation (e.g., 00:1A:2B:3C:4D:5E)

Example: HTML Color Codes

HTML color codes use hexadecimal to represent RGB (Red, Green, Blue) values:

#FF0000

Red: FF (255)
Green: 00 (0)
Blue: 00 (0)

#00FF00

Red: 00 (0)
Green: FF (255)
Blue: 00 (0)

#0000FF

Red: 00 (0)
Green: 00 (0)
Blue: FF (255)

#3498DB

Red: 34 (52)
Green: 98 (152)
Blue: DB (219)

8. Interactive Converter Tool

Result:

-

Conversion Steps:

-

9. Practice Quiz

Created for educational purposes only. Feel free to use this as a reference for understanding number systems.

Shares:

Leave a Reply

Your email address will not be published. Required fields are marked *