#include <stdio.h>
int main() {
if (~0 == 1)
printf("yes\n");
else
printf("no\n");
}
why is the if statement false? can anyone explain?
#include <stdio.h>
int main() {
if (~0 == 1)
printf("yes\n");
else
printf("no\n");
}
why is the if statement false? can anyone explain?
~ Binary One's Complement Operator is unary and has the effect of 'flipping' bits.
So when you do ~0 == 1 it will check for -1 == 1 which is false
~0 is equal to -1, not 1.