I've got a feeling the answer to this is to bit shift, but I can't quite get my brain to grasp it.
I've got some integer values being read, always different, and I need to check if some flags are set by looking at their bit pattern, for example.
Flags:
0x00000002 = Do thing
0x80000000 = Do another thing
Value: 0x80000002
So looking at the value, both flags should be set. But I'm not sure of the best way to implement this. I guess I could use BigInteger.testBit();
, but I don't really want to have to figure out the exact bit in each of the flags (there are a lot).
I can remember doing something like this in C a long time ago, it was something like if (value & flag)
, but Java doesn't seem to like this.
Any ideas of suggestions, would be greatly appreciated.
Thanks