How to efficiently convert a number n to an integer with that many bits set? eg 8 -> 0b11111111?

后端 未结 0 480
猫巷女王i
猫巷女王i 2021-02-20 09:35

How do you efficiently convert a number n to a number with that many low significant bits set? That is, for an 8-bit integer:

0 -> 00000000
1         


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题