How does the bitwise complement operator (~ tilde) work?

后端 未结 15 1636
无人共我
无人共我 2020-11-22 07:46

Why is it that ~2 is equal to -3? How does ~ operator work?

15条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 08:09

    Basically action is a complement not a negation .

    Here x= ~x produce results -(x+1) always .

    x = ~2

    -(2+1)

    -3

提交回复
热议问题