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:

Position23=822=421=220=1
Digit1011
Value1×8=80×4=01×2=21×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

DecimalBinaryCalculation
000
111
2101×21 + 0×20 = 2 + 0 = 2
51011×22 + 0×21 + 1×20 = 4 + 0 + 1 = 5
1010101×23 + 0×22 + 1×21 + 0×20 = 8 + 0 + 2 + 0 = 10
1511111×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:

Position162=256161=16160=1
Digit2A (10)F (15)
Value2×256=51210×16=16015×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

DecimalHexadecimalCalculation
10AA×160 = 10×1 = 10
15FF×160 = 15×1 = 15
16101×161 + 0×160 = 16 + 0 = 16
422A2×161 + A×160 = 32 + 10 = 42
255FFF×161 + F×160 = 15×16 + 15×1 = 240 + 15 = 255
20237E77×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 = 21Remainder: 0
21 ÷ 2 = 10Remainder: 1
10 ÷ 2 = 5Remainder: 0
5 ÷ 2 = 2Remainder: 1
2 ÷ 2 = 1Remainder: 0
1 ÷ 2 = 0Remainder: 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
Position24=1623=822=421=220=1
Digit10110
Value1×16=160×8=01×4=41×2=20×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 = 26Remainder: 7
26 ÷ 16 = 1Remainder: 10 (A)
1 ÷ 16 = 0Remainder: 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
Position162=256161=16160=1
Hex Digit3F (15)2
Value3×256=76815×16=2402×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 group001011010110
Decimal value2136
Hex digit2D6

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 digitB (11)3F (15)
Binary (4 bits)101100111111

Result: B3F16 = 1011001111112

Quick Reference: Binary to Hex Conversion Table

BinaryHex
00000
00011
00102
00113
01004
01015
01106
01117
BinaryHex
10008
10019
1010A
1011B
1100C
1101D
1110E
1111F

6. Arithmetic in Different Number Systems

Binary Addition

Rules for Binary Addition

AdditionResultCarry
0 + 000
0 + 110
1 + 010
1 + 101
1 + 1 + 111
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

SubtractionResultBorrow
0 - 000
1 - 010
1 - 100
0 - 111 (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: