Sir please explain

how int x= ~10 ?
is -11

@Ankit_kumar_3003
X is a int and not unsigned int.
~10 inverts the bits of 10 ie. 1010 to 0101
now this is a negative value to get its magnitude we invert the bits and add 1 i.e twos complement and put the sign
-> 0101 -> 1010 + 1 --> 1011 and sign is negative therefore ans is -11

1 Like