int main()
{
int a=1,b;
b=~1;
printf(""%d",b);
return 0;
}
pls explain by showing bitwise operation it will be helpful to understand...
thanks in advance.......
int main()
{
int a=1,b;
b=~1;
printf(""%d",b);
return 0;
}
pls explain by showing bitwise operation it will be helpful to understand...
thanks in advance.......
It's exactly what you might imagine.
1
is00000001
in binary (number of digits depend on size ofint
on your platform).~1
performs a bitwise-inversion, i.e.111111110
. In two's complement (the most common system of binary arithmetic), this is equal to-2
.