>>= bitwise operations >>

Quote:

>Easy. Each shift is simply an integer divide by 2. Raise 2 to the shift

>value before dividing.

>So:

>>red = (highcolor16 & 0xf800)>>11; // top 5 bits

>becomes:

>red = (highcolor16 And &hf800) \ 2^11

If highcolor16 is an Integer, you will get "sign extension" problems if

the highcolor16 contains the &h8000 bit.

Correct with:

red = red And &h1f

Don't eliminate the first mask because right shifting is not the same

as divide by two when there is a nonzero remainder and the dividend is

NEGATIVE. For example, (-1)/2 = 0 { note, remainder is nonzero } while

(unsigned)(-1)>>1 = 32767 { in 16-bit mode } and (signed)(-1)>>1 = -1 { in

16- or 32-bit mode }.

Henry S. Takeuchi

Seattle, Washington (USA)