- 1
Why ~0 == -1 ?
I saw this prompt in a challenge the other day. I know that tilde (~) is the logical NOT operator and returns rhe complement of the implemented number but İ wonder why it returns -1 for 0??
5 ответов
+ 2
Samsil Arefeen thanks!
0
Formula of find bitwise complement
x=-(x+1)
Here x = 0
So bitwise compliment is -(0+1)
=> x=-(0+1)
=> x=-1
So answer will be -1
https://www.sololearn.com/learn/4076/?ref=app
0
Idk, sorry