# Hexadecimal

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

**Field:** General Knowledge  
**Category:** Math & Statistics  
**Also known as:** Hex, Base 16, Base-16

## 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.

## 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

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

## Example code

```python
>>> hex(255)
'0xff'
>>> int('ff', 16)
255
```

255 written in hex, and hex ff turned back into 255.

## Why it matters

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

## Common mistake

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

## Three principles

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

## Related terms

- [Binary Number System](https://learn.benibix.com/term/general/binary-number)
- [Decimal Number System](https://learn.benibix.com/term/general/decimal-number)
- [Cascading Style Sheets (CSS)](https://learn.benibix.com/term/development/css)
- [Byte](https://learn.benibix.com/term/development/byte)

---

Source: https://learn.benibix.com/term/general/hexadecimal
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-20
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
