Problem
Given a positive integer , determine whether is a power of (i.e. for some integer ) using a single expression. No loops, no recursion, no log tables.
What is the bit pattern of a power of two, and what bit operation exploits it?
Given a positive integer , determine whether is a power of (i.e. for some integer ) using a single expression. No loops, no recursion, no log tables.
What is the bit pattern of a power of two, and what bit operation exploits it?