What is (x & 1) and (x >>= 1)?

后端 未结 5 1303
轮回少年
轮回少年 2020-12-23 02:09

I am trying to do assignment: \"Find the number of bits in an unsigned integer data type without using the sizeof() function.\"

And my design is to convert the integ

5条回答
  •  没有蜡笔的小新
    2020-12-23 03:08

    x & 1 is equivalent to x % 2.

    x >> 1 is equivalent to x / 2

    So, these things are basically the result and remainder of divide by two.

提交回复
热议问题