bitwise not operator

前端 未结 10 990
广开言路
广开言路 2021-01-30 16:24

Why bitwise operation (~0); prints -1 ? In binary , not 0 should be 1 . why ?

10条回答
  •  北恋
    北恋 (楼主)
    2021-01-30 17:00

    Because ~ is not binary inversion, it’s bitwise inversion. Binary inversion would be ! and can (in Java) only be applied to boolean values.

提交回复
热议问题