Hi!

I have a question about left shifting (<<). What happens to the left most bit? Does it disappears or does it go to the right most bit?

And is there a way to influence this?

I ask this because I didn't get the desired results in the following code. It is (or should be) code to calculate the RGB value of white for a given RGBBitCount:

unsigned long RGBValue = (1 << RGBBitCount) - 1;

RGBBitCount is also a unsigned long and either 16, 24 or 32 (in most normal cases).

But when it is 32, 1 << 32 = 1, where it should be 0. So the left most bit goes to the right most one. But that's not what I want and expect... because RGBValue will become 0 in that case, where it should be -1 (or 2^32 - 1 but I don't know exactly what that is )

Is there a way to solve this?

Thanks!

Joren