Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A web designer picks a green colour with the code 2E8B57. The first two hex digits give the amount of red, the next two the green and the last two the blue. Each amount is one byte, from 0 to 255.
Convert each amount to denary.
Hexadecimal is base 16, with the digits 0 to 9 and A to F (10 to 15). One hex digit is one nibble of four bits, so a byte is two hex digits. Binary to hex: split into nibbles from the right and write each one as a digit. Hex to denary: the place values are 4096, 256, 16 and 1.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Given. The colour code 2E8B57, one byte per colour.
Plan. Convert each pair of hex digits with the place values 16 and 1.
Step 1. Red, 2E. .
Step 2. Green, 8B. .
Step 3. Blue, 57. .
Check. Each value is between 0 and 255. The green amount is the largest, which suits a green colour.
Answer: red 46, green 139 and blue 87.
Log in to join the discussion.
Loading…