I wrote a program to read weather a bit of a hex number is either 1 or 0.
Example: is the 4th bit of 0xFF (1111 1111) 1 or 0?
I applied an if statement reading as such:
if((0xFF & (0x01 << 3)) != 0)
True
else
False
All results returned False?
I tried another way too:
sto = 0xFF >> 3
if((sto & 0x01) !=0)
True
else
False
This gets me my result. The only difference from the first and the second is the final result of the first is 0000 1000 and the second is 0000 0001. In both cases I assumed they were true. Is it only reading my least significant bit to determine true or false because i use 0x01?
Example: is the 4th bit of 0xFF (1111 1111) 1 or 0?
I applied an if statement reading as such:
if((0xFF & (0x01 << 3)) != 0)
True
else
False
All results returned False?
I tried another way too:
sto = 0xFF >> 3
if((sto & 0x01) !=0)
True
else
False
This gets me my result. The only difference from the first and the second is the final result of the first is 0000 1000 and the second is 0000 0001. In both cases I assumed they were true. Is it only reading my least significant bit to determine true or false because i use 0x01?