#include<stdio.h>
int main() {
int x = 0x80000000;
printf("%i\n",(((x - 1) >> 31) & 1)); //shows 0 as output
printf("%i\n",!(((x - 1) >> 31) & 1)); //shows 0 as output(expected 1)
}
Why is this happening? As both the statements perform the same operation except the ! operator. Why do the second printf not give 1 as output? From what I know a logical not over 0 gives 1 and logical not over other numbers gives 0. Am I doing something wrong here?