a few extra comments, since you've diverged deeper into colorspace theory:
There are two related color spaces, HSB (sometimes called HSV) and HLS (sometimes called HSL), and they're quite frequently confused and/or mislabelled. Their hue (H) components are identical, but the other two axes differ. Sometimes the only way to know which one you're really using is compare B ("brightness") versus L ("lightness"). HSB's brightness is defined as the maximum value of all three channels, HSL's lightness is defined as the average of the minimum and maximum two channels.
For example, given the color(10,30,100):
Brightness = max(10,30,100) == 100
Lightness = ( min(10,30,100) + max(10,30,100) ) / 2 == 55
Processing clearly uses HSB.
Then there's Photoshop (if you want to make your head spin), which uses HSB in it's color picker, but uses HLS in it's Image->Adjust->Hue/Saturation, and uses its own HsY in the corresponding layer blend modes, and in each case has a different "range" associated with its values. In each case they're using the more appropriate colorspace for the particular task at hand, but it does get confusing trying to describe which "H??" colorspace (as if there were a single one) Photoshop uses.
Then there's yet another similar value, luminance... the value obtained above with the coefficients 0.299, 0.587, 0.114 is the luminance or "Y" channel of colorspaces like YUV and YCbCr (as used in JPEG's) and their kin. It is not equivalent to either HSB's brightness or HLS's lightness. Do note that there ARE several ways to approximate this value with bitwise operations, depending on how much accuracy you need, here's a hint: Y ~= (R+R+R+G+G+G+G+B)/8
Then there's yet another similar value, intensity... since you might eventually see reference to an HSI colorspace, this value is typically computed as just the average of all three channels.
And there's far more to it than that, we haven't even begun to talk about Lab colorspace's lightness, objective versus perceived, white points, gamma curves and such, but that should be enough to think about for a while. :D