bitwise not operator

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

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

10条回答
  •  醉酒成梦
    2021-01-30 16:56

    What you are actually saying is ~0x00000000 and that results in 0xFFFFFFFF. For a (signed) int in java, that means -1.

提交回复
热议问题