I need help on Bit Twiddling

前端 未结 2 420
暗喜
暗喜 2021-01-25 19:17

I love to see people writing Bit Twiddling code but I just can\'t understand it at all. Gone through Hacker\'s Delight and http://graphics.stanford.edu/~seander/bithacks.html, b

2条回答
  •  星月不相逢
    2021-01-25 19:56

    What is the easiest way to calculate the output of bits for example 1 | 2 = 3.

    Write out the numbers as binary. This is how the numbers are really represented.

      00000001
    | 00000010
    = 00000011
    

提交回复
热议问题