ok
i need to check if bit 5 is set (left to right), all the other bits can be set or not but as long as bit 5 is, how would i go about doing this.
00000000 00000000 00000000 00010000
Printable View
ok
i need to check if bit 5 is set (left to right), all the other bits can be set or not but as long as bit 5 is, how would i go about doing this.
00000000 00000000 00000000 00010000
Code://0x01==0001b,0x02==0010b,0x04==0100b,0x08==1000b,0x10==10000
if(0x10 & my32bitvariable)
{
//it is set, so do what you want here
}
More readably,
(It's really the 4th bit, since the counting is zero-based.)Code:if(my32bitvariable & (1 << 4))
There is no such thing as the 0th something.
It's the 5th bit, the one with index 4.
I call the rightmost bit the 0th bit. *shrug*
Sure, and there are 1024 metres in a kilometre :D ;) :p
shh
:p
CB - Take a look in my sig! :D
Where do you think I have it from McCain?
I just read it and thought "cool, that's in my sig!" I never thought that someone as good as you are would "learn" anything from someone like me, I feel honored :D :p
:D
I think it's cool.