def is_power2(num):
 num = int(num)
 return ((num != 0) and ((num & (num - 1)) == 0))

def is_power2 ( num ) : num = int ( num ) return ( ( num != 0 ) and ( ( num & ( num - 1 ) ) == 0 ) )
test if num is a positive integer power of 2 .