This is a trap operator priority . Operator priority determines how operations are “grouped” (for example, how 2*3+4 results in a 2*3 grouping). Adding brackets changes how things are “grouped” (for example, 2*(3+4) leads to grouping 3+4 ).
x^1!=1 equivalent to x^(1!=1) , which can be simplified to x^0 .
int(x^1)!=1 equivalent to (x^1)!=1 (since you manually added parentheses here, the int part is not very important, these are important brackets).
As you can see, x^(1!=1) and (x^1)!=1 do not match.
If your goal is to check the first bit, I would suggest using bit-AND ( & ). Then you can just do if (x & 1) (but be careful, mixing & == will lead to the same problems as before, so use parentheses if you want to write if ((x & 1) == 1) ).
Cornstalks
source share