This is due to CSS color codes:
For hexcode, we can display 16,777,216 colors from # 000000 to #FFFFFF
According to the W3C specifications, the actual RGB percentages range from (from 0.0% to 100.0%), giving you 1,003,003,001 color combinations. (1001 ^ 3)
According to specifications:
Values โโoutside the gamma of the device must be trimmed or displayed in the gamma when the gamma is known: the values โโof red, green and blue must be changed to fall within the range supported by the Device. User agents can perform better color matching from one gamut to another. For a typical CRT monitor, whose gamma is the same as sRGB, the four rules below are equivalent:
I doubt that browsers can actually display all of these values. (but if they do, tell me and ignore the rest of this message)
Im assuming there is some mapping from rgb (in percent) to hex. (but again Im not quite sure how this works)
Ideally, I would like to know the rgb function (in percent) -> HEX
If I had to guess, this would probably be one of these 3.
1) Round to the nearest HEX
2) CEIL to the nearest HEX
3) FLOOR to the nearest HEX
The problem is that I need to be precise regarding the display, and I have no idea where to look. There is no way that my eyes can distinguish color at this level, but maybe there is some clever way to test each of these 3.
It may also be browser dependent. Can this be verified?
EDIT:
Firefox seems to round from empirical testing.
EDIT:
I am viewing Firefox source code right now,
nsColor.h
It seems that Fiefox has only room for 255 values โโfor each R, G, and B. Assuming rounding might be the answer, but maybe something is happening with the alpha channel.