def is_power_of_two(a):
  """Return whether the argument, cast to int, is a power of 2."""
  a = int(a)
  # Bit manipulations. A power of 2 has a bit represetenation like 0...010...0.
  # For such a number subtracting 1 from it turns it into 0...001...1, so ANDing
  # a-1 and a should yield 0.
  return a > 0 and ((a - 1) & a) == 0