Level 0 · Module 1
Hexadecimal
Use base sixteen as a compact, readable shorthand for binary data.
Not completed
By the end, you can
- Recognize the sixteen hexadecimal symbols.
- Convert a four-bit binary group to hexadecimal.
- Explain why hexadecimal is used in computing.
Summary
Hexadecimal, usually called hex, is another way to write numbers. It uses sixteen symbols: 0–9, then A–F. One hex digit represents exactly four binary bits, so hex makes long binary values easier for people to read.
Introduction
Binary works well inside circuits but is tiring for people to scan. Hex keeps the exact same value while putting the bits into short, readable groups.
Explanation
After 9, hex uses letters: A means decimal 10, B means 11, through F, which means 15. To change binary into hex, split the bits into groups of four from the right. For example, 1111 0010₂ becomes F2₁₆: 1111 is F and 0010 is 2. Since a byte has eight bits, two hex digits represent one byte.
Real-world example
The color #2A7FFF contains three byte-sized hex pairs: red 2A, green 7F, and blue FF.
Designers can exchange an exact color without writing 24 binary digits.
Group bits in fours
Interactive exploration
A byte written as hexadecimal
Step 1 of 4
Hex is not more precise than binary; it is simply a shorter label for the same bit pattern. It is useful when people need to inspect binary data because four-bit groups are quick to convert.
Code example
const value = 242;
console.log(value.toString(16).toUpperCase()); // F2
console.log(Number.parseInt('F2', 16)); // 242Common mistakes
- Reading
Bas a letter rather than decimal 11 in a hex number. - Grouping binary digits in threes; that is useful for octal, not hex.
- Assuming every
#value is a color; context determines its meaning.
Quiz
Knowledge check
Try it
Decode a byte
Convert 7B₁₆ to binary by replacing each hex digit with four bits, then find its decimal value.
Key takeaways
- Hex uses sixteen symbols: 0–9 and A–F.
- One hex digit maps exactly to four bits.
- Hex is compact notation for binary values such as bytes and addresses.