c - Calculation of Bit wise NOT -
how calculate ~a
manually? seeing these types of questions often.
#include <stdio.h> int main() { unsigned int = 10; = ~a; printf("%d\n", a); }
the result of
~
operator bitwise complement of (promoted) operand
c11dr §6.5.3.3
when used unsigned
, sufficient mimic ~
exclusive-or uint_max
same type , value (unsigned) -1
. @eof
unsigned int = 10; // = ~a; ^= -1;
Comments
Post a Comment