Using the digits 000000 to FFFFFF, hexadecimal color codes are used to represent nearly every color seen on the Internet. Here is how hexadecimal colors actually work.

How Hexadecimal Colors Work

In hexadecimal, the numbers A through F are used to extend the base-10 decimal system to a base-16 system:

0 = 0

1 = 1

[...]

9 = 9

A = 10

B = 11

C = 12

D = 13

E = 14

F = 15

A hex color is equivalent to an RGB color:

RGB(0,0,0) is the same as #000000

RGB(255,255,255) is the same as #FFFFFF

A hex color consists of three sets of two hexadecimal digits. The first two are the amount of red, the second two are the amount of green, and the last two are the amount of blue.

FF = 255

Decimal to Hexadecimal Conversion

Note that while this converter is limited to hexadecimal numbers from 000000 to FFFFFF, hexadecimal can be used to represent any number that can be represented using decimal notation.

Also note that hexadecimal as a general concept does not require padding zeros to six positions. This is a convention used for denoting hexadecimal colors.

Why the R, G, and B are between 0 and 255

The reason why the max is 255 is because:

A byte of data is eight bits ight bits is equal to 2^8 possible values 2^8 = 256 Since 0 is one of the 256 possible values, a byte frequently represents an integer from 0 to 255

The point being that a hexadecimal color has one byte of data for each of the the R G and B values.

Share This Post

Download more RAM. 🐏 ⨉ 0 Posted by August R. Garcia 1 year ago 🕓 Posted at 31 March, 2019 19:16 PM PDT