Introduction to the base-16 system used by programmers to simplify long binary strings.
Have you ever wondered why website colors are defined by codes like #FF5733? Why would a computer, which only understands 1s and 0s, suddenly need the letter 'F' to show you a shade of orange?
Computers think in binary (Base-2), using only and . While this is perfect for hardware, it is a nightmare for humans. A single standard byte of data requires 8 digits (e.g., ). As programs grow, these strings become miles long, making them nearly impossible to read or debug without making mistakes. This is known as binary bloat. To solve this, programmers use Hexadecimal (Base-16). Hexadecimal is a 'shorthand' that allows us to represent large binary numbers in a much more compact, human-readable format. Because is a power of (), one hexadecimal digit perfectly represents exactly four binary bits.
Quick Check
Why is hexadecimal preferred over decimal when programmers want to simplify binary code?
Answer
Hexadecimal aligns perfectly with binary because one hex digit represents exactly four bits (a nibble), making conversion much cleaner than decimal.
In our everyday decimal (Base-10) system, we have ten symbols: through . However, Hexadecimal needs sixteen distinct symbols. To fill the gap after , we use the first six letters of the alphabet. This means that in Hex, the letter A actually represents the quantity , and F represents . The full set of characters is: . When you see a letter in a computer code, it isn't a word; it's a specific numerical value!
To understand Hex, you must memorize the 'letter-to-number' map: 1. 2. 3. 4. 5. 6.
If a programmer says they have items, they have in decimal.
Quick Check
What is the decimal value of the hexadecimal character 'C'?
Answer
12
The magic of Hexadecimal lies in its density. In binary, four bits are called a nibble. Since , a single nibble has exactly possible combinations (from to ). This means any 4-bit binary string can be replaced by exactly one hex character. For example, the binary string is in decimal, which is simply in Hex. By using Hex, we reduce the length of binary strings by . An 8-bit byte like becomes just two characters: .
Convert the binary to Hexadecimal: 1. Calculate the decimal value: . 2. Look up on the Hex map: . 3. Result: .
Convert the 8-bit binary to Hex: 1. Split the byte into two nibbles: and . 2. Convert the first nibble (): . In Hex, is . 3. Convert the second nibble (): . In Hex, is . 4. Combine them: .
How many binary bits are represented by a single hexadecimal digit?
Which of the following is the correct decimal value for the hex digit 'D'?
Hexadecimal is used by computers to perform calculations faster than binary.
Review Tomorrow
In 24 hours, try to write down the decimal values for A, B, C, D, E, and F without looking at your notes.
Practice Activity
Find a 'Hex Color Picker' online. Try to guess which letters (A-F) will make a color brighter or darker!