Meaning of bitwise and(&) of a positive and negative number?

后端 未结 8 1867
名媛妹妹
名媛妹妹 2021-02-04 11:59

Can anyone help what n&-n means?? And what is the significance of it.

8条回答
  •  终归单人心
    2021-02-04 12:25

    It's just a bitwise-and of the number. Negative numbers are represented as two's complement.

    So for instance, bitwise and of 7&(-7) is x00000111 & x11111001 = x00000001 = 1

提交回复
热议问题