Speaking of these modulus operators... I believe that they are pretty much useless for creating RGB values in 16-bit mode EVEN IF YOU WANT TO NORMALIZE A 24-BIT COLOR. The reason for this is that you really want to save the most significant bits of each 8-bit component, not the least significant as the modulus operator will do.
You would be much better off making sure your initial components are between 0-255 (just program it that way and use assertions or something to make sure its true, don''t try using % to force values into this range.)
Then, use division (or simply bit shifting) to remove the right most bits and achive the propper length:
RGB16 = ((red >> 3) << 11) + ((green >> 2) << 5) + ((blue >> 3))
The reason for this additional shifting becomes clear after considering a couple special examples...
A fairly dark green: 00111111 would become bright green: 111111 using the % operator which is clearly not correct. Using the >> operator whe get 001111 which is scaled corectly to the new range.
A meduim green: 10000000 would become black: 000000 using the % operator! This is certainly incorrect, but with the >> operator you get 100000 which is *still* medium green in the new color range.
Hope this helps.