Stewdent.eu
▾

Hexadecimal

Hexadecimal is a base-16 number system that computer scientists use as a shorthand for binary.

Last updated: 19 December 2025

★★☆☆☆ Level 2computingDatabinaryhexadecimalhex3 min read

Report an error

What is Hexadecimal?

Hexadecimal (often shortened to hex) is a number system that uses 16 symbols instead of the usual 10. It counts: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

After 9, we use letters:

DecimalHexBinary
10A1010
11B1011
12C1100
13D1101
14E1110
15F1111
Note

Hex numbers are often written with a 0x prefix or a # symbol to show they are hexadecimal — for example, 0xFF or #FF0000 (the colour red in HTML).

Why Do We Use Hexadecimal?

Binary numbers get very long very quickly. The decimal number 255 in binary is 11111111 — eight digits. In hexadecimal it is simply FF — just two digits.

Each hex digit represents exactly 4 binary bits (called a nibble). This makes converting between hex and binary very easy, and it makes long binary numbers much more readable for humans.

Converting Between Hex and Binary

To convert binary to hex, split the binary number into groups of 4 bits from the right, then replace each group with its hex digit.

Example: Convert 11010110 to hex.

  • Split: 1101 0110
  • 1101 = 13 = D
  • 0110 = 6 = 6
  • Result: D6

To go the other way, replace each hex digit with its 4-bit binary pattern:

  • D = 1101, 6 = 0110
  • Result: 11010110

Hex in Real Life

You will see hexadecimal everywhere in computing:

  • Colours in HTML/CSS: #FF5733 means Red=FF (255), Green=57 (87), Blue=33 (51)
  • Memory addresses: RAM locations are shown in hex, e.g. 0x7FFF1234
  • Error codes: Windows "Blue Screen" errors show hex codes like 0x0000007E
Tip

When you see a colour code like #3A9FD2 in a web page, you can now read it! #3A is red, #9F is green, and #D2 is blue — all in hexadecimal.

Converting Hex to Decimal

To convert a two-digit hex number to decimal, multiply the left digit by 16 and add the right digit.

Example: B4 in decimal = (11 × 16) + 4 = 176 + 4 = 180.

Practice Problems

Convert the binary number 10111001 to hexadecimal. Show your working by splitting into nibbles.

Show answer
Split: 1011 | 1001. 1011 = 11 = B. 1001 = 9. Result: B9.

A web designer uses the HTML colour #00FF00. What colour is this, and what are the decimal values of its red, green, and blue components?

Show answer
#00FF00 is pure green. Red = 00 = 0, Green = FF = 255, Blue = 00 = 0. Maximum green, no red or blue.