两个很经典的位运算记录

记录一下:

x&(-x):保留二进制下最后出现的1的位置,其余位置置0
x&(x-1):消除二进制下最后出现1的位置,其余保持不变

Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.

请我喝杯咖啡吧~

支付宝
微信