Arm/pow2

From ASMBits

arm/popcountPrevious

Write a function that will return whether its parameter is a power of 2. The parameter is an unsigned integer and will not be 0.

int pow2(unsigned int num);

Expected solution length: Around 5 lines.

Sample Input

pow2(4)

Sample Output

r0=1

It is possible to do this without a loop. Consider the binary representations of (2n) and (2n-1).

Write your solution here

Upload a source file...