Quantcast
Channel: How to check if a number is a power of 2 - Stack Overflow
Viewing all articles
Browse latest Browse all 38

Answer by bugs king for How to check if a number is a power of 2

$
0
0
bool isPowerOfTwo(int x_){  register int bitpos, bitpos2;  asm ("bsrl %1,%0": "+r" (bitpos):"rm" (x_));  asm ("bsfl %1,%0": "+r" (bitpos2):"rm" (x_));  return bitpos > 0 && bitpos == bitpos2;}

Viewing all articles
Browse latest Browse all 38

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>