I have a question I am not great if it comes to low level programming so quick question I have a byte and each 2 bits in that byte mean something for example:
my byte is 204 so that should be 1100 1100 according to calculator so
bits 0..1 mean status of type 1 bits 3..2 mean status of type 2 bits 5..4 mean status of type 3 bits 7..6 mean status of type 6 So to check all values I use:
var state = 204 var firstState = (state >> 0) & 2 var secondState = (state >> 2) & 2 var thirdState = (state >> 4) & 2 var fourthState = (state >> 6) & 2 But this looks odd I expext results
firstState = 0 secondState = 3 thirdState = 0 fourthState =3 but I am receiving 0,2,0,2. So what am I doing wrong?
& 3? or perhaps more clearly:& 0b11?