0
If int a=5; then what is the value of (~a)
6 Réponses
+ 1
It flips all the bits.
5 = 0101
~5 = 1010
I am also not sure if it is 1's compliment or 2's compliment but that's how it works. ☺️
+ 1
Thanks everyone 😃
0
Most significant bit? Or 1's complement?
0
Yeah..but if u code then output is -6...how's that?
0
To understand it you need to know 2's complement.
https://www.programiz.com/c-programming/bitwise-operators#complement
In short ~n = -(n+1)
~5 = -(5+1) = -6