0

If int a=5; then what is the value of (~a)

13th Oct 2019, 3:31 PM
Lonestarrrr
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. ☺️
13th Oct 2019, 5:54 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 1
Thanks everyone 😃
14th Oct 2019, 3:41 AM
Lonestarrrr
0
Most significant bit? Or 1's complement?
13th Oct 2019, 3:54 PM
Lonestarrrr
0
Yeah..but if u code then output is -6...how's that?
13th Oct 2019, 6:18 PM
Lonestarrrr
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
13th Oct 2019, 6:43 PM
Denise Roßberg
Denise Roßberg - avatar