Negation zero _ if condition | SoloLearn: Learn to code for FREE!

0

Negation zero _ if condition

https://code.sololearn.com/cxsbqpJwBSbn/?ref=app Hi friends.. here I am getting output as no .......but ~0=1 . So (~0==1 ) I think this statement is true na. Then why it's getting false....? Could you explain...?

6/9/2019 5:33:58 AM

malepu rakesh

3 Answers

New Answer

+7

malepu rakesh You might be confusing ~ and ! (bitwise not vs. logical negation) ==> (!0 == 1) // true

+6

malepu rakesh ~ bitwise operator changes the sign of a number and subtract 1 from it so ~0 = -1 not 1 similarly ~-1 = 1 (change sign) then subtract 1 so ~-1 = 0

+2

Thank you friends😊