Base-16

Hexadecimal Number System

Hexadecimal writes binary values in a compact notation that people can scan quickly. It is widely used in memory views, colour codes, encodings, and low-level debugging.

By The End Of This Lesson

  • Read hexadecimal digits and calculate their contributions using powers of sixteen.
  • Convert between hexadecimal and binary by grouping four bits at a time.
  • Distinguish a number's value from its notation and displayed width.

Why Hex Works Well

4 bits per digit

Each hexadecimal character maps exactly to one nibble, which makes binary conversion fast and predictable.

Compact format

11111111 can be written as FF in logs, dumps, and configuration values. The value stays the same; this is a change of notation, not data compression.

Real-world usage

Memory addresses, colour values, packet data, hashes, and file headers often appear in hexadecimal.

Place Value

Every hexadecimal digit contributes based on its position, using powers of 16. The digits are 0–9 followed by A (10), B (11), C (12), D (13), E (14), and F (15). Positions count from zero on the right; the rightmost place is 160 = 1. For example, A and F in 1A3F contribute ten and fifteen times their respective place values.

Position 3

16 to the power of 3

Value:4096

Digit:1

1 × 4096 = 4096

Position 2

16 to the power of 2

Value:256

Digit:A (10)

10 × 256 = 2560

Position 1

16 to the power of 1

Value:16

Digit:3

3 × 16 = 48

Position 0

16 to the power of 0

Value:1

Digit:F (15)

15 × 1 = 15

Example Breakdown

1A3F16 = 671910

1 × 4096 + 10 × 256 + 3 × 16 + 15 × 1

4096 + 2560 + 48 + 15 = 6719

Why It Helps

Multiply each hexadecimal digit by its place value, then add the contributions to find the decimal value. The same place-value idea works in decimal, binary, and hexadecimal.

Worked Example: One Digit, Four Bits

There are sixteen four-bit patterns, so one hexadecimal digit can describe each pattern. In 2A, convert the 2 to a four-bit group and the A (decimal 10) to another. Preserve all four places in each group.

2 → 0010A → 1010

2A16 = 0010 10102

2 × 16 + 10 × 1 = 4210

To go from binary to hex, group from the right in fours, adding leading zeros to the left group if needed. Convert each group separately. For example, 1111 and 00001111 are the same value, written as F or 0F. The two-digit form makes a byte's width clear.

The prefix 0x marks a hexadecimal number in many programming contexts; it is not another digit. Thus 0x2A and 2A describe the same hex value.

Hex Converter

Predict the result, then enter up to 16 hexadecimal digits, with an optional 0x prefix. This tool converts whole non-negative values exactly and keeps leading zeros in the displayed binary width.

Hex

2A

Decimal

42

Binary

00101010

Hexadecimal 2A is decimal 42. Its binary form is shown above.

Practise The Nibble Method

Write the grouped binary for 3C and A5 without the converter. Check each four-bit group with the weights 8, 4, 2, and 1. Then use the Hex Switch Game to build the bytes. Explain each nibble before comparing the readout.

Reveal the practice answers

3C16 = 0011 11002 = 6010

A516 = 1010 01012 = 16510

For 3C, the nibbles have values 3 and 12. For A5, they have values 10 and 5. Check the decimal totals using powers of sixteen.

Check Your Understanding

Try these without the converter or reference table. Check each answer to reveal its explanation.

1. What is the decimal value of 2A in hexadecimal?

Choose an answer before checking. You can change your choice and try again.

2. Which grouped binary pattern matches hexadecimal 3C?

Choose an answer before checking. You can change your choice and try again.

3. What is the difference between hexadecimal F and 0F?

Choose an answer before checking. You can change your choice and try again.