How to unset N right-most bits

前端 未结 0 341
谎友^
谎友^ 2021-01-21 04:19

There is a relatively well-known trick for unsetting a single right-most bit:

y = x & (x - 1) // 0b001011100 & 0b001011011 = 0b001011000 :)
相关标签:
回答
  • 消灭零回复
提交回复
热议问题