CCalclabhub

Color

Hex to RGB

Each pair of hex digits is a base-sixteen number from 0 to 255, in red, green and blue order.

The Formula

R = 0xRR, G = 0xGG, B = 0xBB

Each pair of hex digits is a base-sixteen number from 0 to 255, in red, green and blue order.

SymbolMeaning
h1High nibble
h2Low nibble

What Each Symbol Means

h1digit

High nibble

The first hex digit of the pair, worth sixteen times its value.

h2digit

Low nibble

The second hex digit of the pair, worth its face value.

See It Worked With Real Numbers

A formula on its own does not tell you which number goes where. The how to convert colors page applies this equation to a concrete case, shows every intermediate step, and names the mistakes that produce a wrong answer even when the algebra is right.

Where This Formula Appears

This equation is the working core of How To Convert Colors, filed under Unit Conversion. Every number the guide produces comes from substituting into this one line.