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

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

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

8条回答
  •  别那么骄傲
    2021-02-04 12:34

    I would add a self-explanatory example to the Mark Randsom's wonderful exposition.

    010010000 | +144 ~
    ----------|-------
    101101111 | -145 +
            1 |
    ----------|-------
    101110000 | -144 
    
    101110000 | -144 & 
    010010000 | +144
    ----------|-------
    000010000 |   16`
    

提交回复
热议问题