## loststudent88

Hello I am working on a program and have become pretty confused...
I am supposed to write a program that will convert html colours expressed as 6 hexadecimal digits to their individual red, green, and blue components expressed in decimal. If anyone can help me out with some pointers of how to do this then that would be great. Thanks

## jonsca 1,059

What have you tried so far? It's a matter of parsing the hex digits 2 at a time and converting them to decimal (for digits, convert to an int by subtracting '0' and by using a switch statement to convert a or A to 10, etc.).

## firstPerson 761

First worry about converting hex values into decimal, specifically into
R,G,B values in base 10.

Suppose the colors in hex, is 0xFF00FF.

The first 2 hex values ,FF, is (R)ed.
The second 2 hex values, 00 is (G)reen.
The third 2 hex values, FF, is (B)lue.

Now in general say the colors, are 0xUVWXYZ,
where UV is the red component, WX is the green component, and
YZ is the blue component. U,V,W,X,Y,Z can be any values.

1) Your first mission is to extract each 2 sequential digit after the 0x.
2) Report back after you get that done, or if you have trouble getting it done.