A bit is a binary digit: 0 or 1. Moving one position to the left doubles its place value. An 8-bit word has weights 128, 64, 32, 16, 8, 4, 2, 1. Add the weights of the positions containing 1 to read its unsigned value.
Hexadecimal groups four bits into one digit. The digits 0–9 are followed by A–F for values 10–15. Split a byte into two nibbles and convert each independently: 1010 0110 becomes A6.
The representation changes, but the value does not. Leading zeroes show the chosen width. The prefixes 0b and 0x indicate binary and hexadecimal; they are not part of the value.
Explain it before you practise
Look away from the example. Explain why it works and predict a boundary case. Then check your reasoning.
Why do two hexadecimal digits represent exactly one byte? What happens to the value when you add a leading zero?
Check your reasoning
One hexadecimal digit encodes 16 possibilities, exactly four bits. Two digits encode eight bits. A leading zero adds no set-bit weight, so the value stays the same.
Cement this knowledge
Solve ten fresh questions without the worked example. Mistakes return during the session; spaced review helps you recall the method on later days.
Practice this topic →