Why do we always divide RGB values by 255?

rgb
Tabish Sohail picture Tabish Sohail · Dec 10, 2013 · Viewed 52.3k times · Source

Why do we always divide our RGB values by 255? I know that the range is from [0-1]. But why dive only by 255? Can anyone please explain me the concepts of RGB values?

Answer

Tarun Chaudhary picture Tarun Chaudhary · Dec 10, 2013

RGB (Red, Green, Blue) are 8 bit each.
The range for each individual colour is 0-255 (as 2^8 = 256 possibilities).
The combination range is 256*256*256.

By dividing by 255, the 0-255 range can be described with a 0.0-1.0 range where 0.0 means 0 (0x00) and 1.0 means 255 (0xFF).