Masking a bit in C returning unexpected result
- by Eamorr
0x7F000000 is 0111 1111 0000 0000 0000 0000 0000 0000 in 32 bit binary.
0x01000058 is 0000 0001 0000 0000 0000 0000 0101 1000.
When I AND the two numbers together I expect 0000 0001 0000 0000 0000 0000 0000 0000, but for some reason I get 0.
Here is my code:
#define MASK_binop 0x80000000
#define MASK_operation 0x7F000000
int instruction=atoi(line);
if((MASK_binop & instruction)>0)
printf("binop\n");
else if((MASK_operation & instruction)>0)
printf("operation\n");
Each of the above comparisons keeps returning zero. Is it something to do with 32/64 bits? I'm using 64-bit compiler.