Bit masking (or not)?

The R, G and B did not need to be floats and can be efficiently extracted from the color integer with bit manipulation.
The luminance will be a float.
You may need to use floating point math in such cases and can cast results as required.

I edited my previous post for clarity on context.

@solub made some approximations here to optimize performance:

There are also examples of extracting and setting colors without the helper functions:
Color to grayscale algorithm - #5 by solub

:)