#65443 - netriones - Tue Jan 03, 2006 9:11 am
The code: "#define RGB(r,g,c) ((r)+(g<<5)+(b<<10)) " convert three R,G,B values into 15-bit color format, but I don't understand how it works
what is the << doing here? g<<5, b<<10
#65447 - kusma - Tue Jan 03, 2006 9:44 am
<< is the bitsift left operator, and it shifts the bits left. the number 5 (101 in binary) shifted left with 3 is 40 (101000). similarly, you have the >> operator that shifts bits right.
also note that operators in c++ can be overloaded, and what you might have seen from stringstreams and such using the <<-operator does not relate to bitshifting at all. bitshifting only works on integer-types.