Skip to content
BENIBIX Learn

Hexadecimal

General🔢 Math & StatisticsNumber Systems

Also known as Hex, Base 16, Base-16

A way of writing numbers with sixteen digits, 0 to 9 and A to F.

Think of it like

Think of it like a short way to write a long row of switches. One letter stands for four of them.

Example

Jack sets a button colour to #FF0000. FF is 255 in hex, so the red part is turned all the way up.

Why it matters

Hex shows up in colours, file data and error codes. Reading it saves a lot of guessing.

Definition

Hexadecimal writes numbers using sixteen digits: 0 to 9, then A to F for ten to fifteen. Each place is worth sixteen times the place to its right. One hex digit stands for exactly four binary bits, so it is a short way to write binary. Colours on the web, like #FF0000 for red, are written in hex. So are memory addresses and many error codes.

Example code

python
>>> hex(255)
'0xff'
>>> int('ff', 16)
255
255 written in hex, and hex ff turned back into 255.

Common mistake

Reading a hex number like 10 as ten. In hex, 10 means sixteen.

Key takeaways

  1. 1
    Sixteen digits. 0 to 9, then A to F.
  2. 2
    Four bits each. A short way to write binary.
  3. 3
    Seen in colours. Like #FF0000 for red.