👁 Preview — Study, Practice and Revise are open; mock tests and the rest of the syllabus unlock on subscription. Unlock all · ₹4,999
← Back to Number System
Study mode

Hexadecimal

Introduction to Number Systems and the Importance of Hexadecimal

Numbers are the foundation of mathematics and everyday life. But did you know that the way we write numbers depends on a system called a number system? A number system defines how numbers are represented using a set of symbols and a base or radix. The most familiar number system is the decimal system, which uses base 10 and digits from 0 to 9.

However, in fields like computing and digital electronics, other number systems are more practical. This is because computers work with binary data (base 2), which can be long and hard to read. To simplify this, number systems like octal (base 8) and hexadecimal (base 16) are used.

Among these, the hexadecimal system is especially important. It is widely used in programming, memory addressing, and digital color representation. Understanding hexadecimal helps you read and write data in a form that is both compact and easy to convert to binary.

Hexadecimal Number System

The hexadecimal number system, often called hex, is a base-16 system. This means it uses 16 unique symbols to represent numbers. These symbols are:

Hexadecimal Digits and Their Decimal Equivalents
Hex Digit 0 1 2 3 4 5 6 7 8 9 A B C D E F
Decimal Value 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Notice that after 9, letters A to F are used to represent decimal values 10 to 15. This is because we need 16 symbols in total for base 16.

Place Value in Hexadecimal

Just like the decimal system, where each digit's place value is a power of 10, in hexadecimal each digit's place value is a power of 16. The rightmost digit is multiplied by \(16^0 = 1\), the next digit to the left by \(16^1 = 16\), then \(16^2 = 256\), and so on.

For example, the hexadecimal number 3F2 represents:

\[3 \times 16^2 + F \times 16^1 + 2 \times 16^0\]

Since \(F = 15\) in decimal, this is:

\[3 \times 256 + 15 \times 16 + 2 \times 1 = 768 + 240 + 2 = 1010\]

Conversion Between Hexadecimal and Decimal

Converting between hexadecimal and decimal is essential to understand and work with hex numbers effectively.

Hexadecimal to Decimal Conversion

To convert a hexadecimal number to decimal, expand it using place values and sum the results. The general formula is:

Hexadecimal to Decimal Conversion

\[N = \sum_{i=0}^{n-1} d_i \times 16^i\]

Sum of each digit multiplied by 16 raised to the power of its position

N = Decimal number
\(d_i\) = Digit at position i (0 to 15)
n = Number of digits
i = Position index starting from 0 at rightmost digit

Decimal to Hexadecimal Conversion

To convert a decimal number to hexadecimal, use the repeated division and remainder method:

  1. Divide the decimal number by 16.
  2. Write down the remainder (this will be a hex digit).
  3. Divide the quotient again by 16, and repeat until the quotient is zero.
  4. The hexadecimal number is the remainders read from bottom to top.

Decimal to Hexadecimal Conversion

Repeated division by 16, collecting remainders

Divide decimal number by 16 repeatedly and collect remainders as hex digits

Divide decimal number by 16 =
Remainders form hex digits from least significant to most significant =
graph TD    A[Start] --> B{Conversion Type?}    B -->|Hex to Decimal| C[Expand digits using place values]    C --> D[Calculate sum]    D --> E[Decimal Result]    B -->|Decimal to Hex| F[Divide decimal by 16]    F --> G[Record remainder]    G --> H{Quotient zero?}    H -->|No| F    H -->|Yes| I[Read remainders bottom to top]    I --> J[Hexadecimal Result]

Conversion Between Hexadecimal and Binary/Octal

Since computers operate in binary (base 2), converting between hexadecimal and binary is straightforward. Each hex digit corresponds exactly to 4 binary bits (because \(2^4 = 16\)). Similarly, octal (base 8) can be linked to binary by grouping bits in sets of 3.

Hexadecimal Digits with Binary and Octal Equivalents
Hex Binary (4 bits) Octal
000000
100011
200102
300113
401004
501015
601106
701117
8100010
9100111
A101012
B101113
C110014
D110115
E111016
F111117

How to convert:

  • Hex to Binary: Replace each hex digit with its 4-bit binary equivalent.
  • Binary to Hex: Group binary digits in sets of 4 (from right to left) and replace each group with the corresponding hex digit.
  • Hex to Octal: Convert hex to binary first, then group binary digits in sets of 3 (from right to left) to get octal digits.

Arithmetic Operations in Hexadecimal

Arithmetic in hexadecimal follows the same principles as in decimal, but with base 16. This means carry and borrow happen when sums or differences cross 15 (decimal 15).

Addition

To add two hex digits, convert them to decimal, add them, then convert back to hex. If the sum is 16 or more, carry 1 to the next higher digit.

Hexadecimal Addition

\[Sum = (d_1 + d_2 + carry) \bmod 16\]

Add digits and carry, result digit is modulo 16, carry is integer division by 16

\(d_1, d_2\) = Hex digits
carry = Carry from previous addition

Subtraction

Subtract hex digits by converting to decimal. If the minuend digit is smaller than the subtrahend digit, borrow 1 (which equals 16 in decimal) from the next higher digit.

Hexadecimal Subtraction

Difference = (minuend - subtrahend - borrow)

Subtract digits, borrow 16 if needed

minuend = Digit being subtracted from
subtrahend = Digit to subtract
borrow = Borrowed 1 (16 decimal) if needed

Multiplication and Division

Multiplication and division are performed similarly by converting hex digits to decimal, performing the operation, and converting the result back to hex. For multi-digit numbers, use long multiplication or division methods adapted to base 16.

Hex Addition: A3 + 1C Step 1: Convert digits to decimal A = 10, 3 = 3; 1 = 1, C = 12 Step 2: Add right digits: 3 + 12 = 15 (F hex), carry = 0 Step 3: Add left digits: 10 + 1 + 0 = 11 (B hex) Result: BF
{"points": [ "Hexadecimal uses digits 0-9 and letters A-F to represent values 0-15.", "Each hex digit represents 4 binary bits.", "Conversions between hex and decimal use place value expansion and repeated division.", "Hex arithmetic requires careful carry and borrow handling based on base 16." ], "conclusion": "Mastering hexadecimal is essential for computing and digital electronics."}

Worked Examples

Example 1: Convert Hexadecimal 2F to Decimal Easy
Convert the hexadecimal number 2F to its decimal equivalent.

Step 1: Identify the digits and their decimal values.

2 = 2, F = 15

Step 2: Use place value expansion:

\(2 \times 16^1 + 15 \times 16^0 = 2 \times 16 + 15 \times 1 = 32 + 15 = 47\)

Answer: The decimal equivalent of hex 2F is 47.

Example 2: Add Hexadecimal Numbers A3 and 1C Medium
Add the hexadecimal numbers A3 and 1C.

Step 1: Convert each digit to decimal.

A = 10, 3 = 3; 1 = 1, C = 12

Step 2: Add the rightmost digits: 3 + 12 = 15 (which is F in hex). No carry since 15 < 16.

Step 3: Add the left digits plus carry: 10 + 1 + 0 = 11 (which is B in hex).

Step 4: Combine the results: left digit B and right digit F.

Answer: A3 + 1C = BF in hexadecimal.

Example 3: Convert Decimal 255 to Hexadecimal Medium
Convert the decimal number 255 to hexadecimal.

Step 1: Divide 255 by 16:

255 / 16 = 15 remainder 15

Step 2: Divide quotient 15 by 16:

15 / 16 = 0 remainder 15

Step 3: Write remainders from bottom to top: 15 (F), 15 (F)

Answer: Decimal 255 = Hexadecimal FF.

Example 4: Multiply Hexadecimal Numbers 1A and 3 Hard
Multiply the hexadecimal numbers 1A and 3.

Step 1: Convert hex digits to decimal.

1A = \(1 \times 16 + 10 = 26\), 3 = 3

Step 2: Multiply decimal values: 26 x 3 = 78

Step 3: Convert 78 back to hexadecimal using division:

78 / 16 = 4 remainder 14

4 / 16 = 0 remainder 4

Remainders from bottom to top: 4 (4), 14 (E)

Answer: 1A x 3 = 4E in hexadecimal.

Example 5: Convert Hexadecimal 7B to Binary and Octal Medium
Convert the hexadecimal number 7B to binary and octal.

Step 1: Convert each hex digit to 4-bit binary:

7 = 0111, B = 1011

So, 7B in binary is 01111011.

Step 2: Group binary digits in sets of 3 for octal (from right):

0 111 101 1 -> Add leading zero to make full groups: 000 111 101 011

Groups: 000, 111, 101, 011

Step 3: Convert each group to octal digit:

000 = 0, 111 = 7, 101 = 5, 011 = 3

Answer: Hex 7B = Binary 01111011 and Octal 0753.

Tips & Tricks

Tip: Memorize hex digits 0-9 and A-F with their decimal equivalents.

When to use: Essential for quick conversions and arithmetic in hexadecimal.

Tip: Group binary digits in sets of 4 to convert easily between binary and hexadecimal.

When to use: When converting numbers between binary and hex.

Tip: Use repeated division and remainder method for decimal to hex conversion.

When to use: For converting large decimal numbers to hexadecimal efficiently.

Tip: Remember carry in hex addition occurs when sum exceeds 15 (decimal 15), not 9.

When to use: During hexadecimal addition problems to avoid errors.

Tip: Use place value expansion to convert hex to decimal instead of memorizing large numbers.

When to use: When converting any hexadecimal number to decimal for accuracy.

Common Mistakes to Avoid

❌ Confusing hexadecimal digits A-F with decimal numbers greater than 9.
✓ Remember A=10, B=11, ..., F=15 in decimal.
Why: Treating letters as letters rather than numbers leads to incorrect calculations.
❌ Incorrect carry handling in hexadecimal addition, applying decimal carry rules.
✓ Carry over when sum of digits exceeds 15 (not 9 as in decimal).
Why: Hexadecimal base is 16, so carry rules differ from decimal.
❌ Forgetting to convert hex digits to decimal before arithmetic operations.
✓ Convert hex digits to decimal equivalents before performing addition or subtraction.
Why: Directly adding letters without conversion leads to wrong results.
❌ Mixing up place values during conversion, e.g., using wrong powers of 16.
✓ Use correct powers of 16 starting from rightmost digit as \(16^0\).
Why: Incorrect indexing causes wrong decimal values.
❌ Not grouping binary digits correctly when converting to hex.
✓ Group binary digits in sets of 4 starting from right.
Why: Improper grouping leads to wrong hex digits.
Curated videos per subtopic
Top YouTube explainers, AI-ranked for your exam and language. Unlocks with subscription.
Unlock

Try Practice next.

Progress tracking is paywalled — subscribe to mark subtopics as understood and save your streak.

Go to practice →
Ask a doubt
Hexadecimal · 10 free messages
Ask me anything about this subtopic. You have 10 free messages this session — chat history isn't saved in preview.