Adding isPowerOf2 to BinaryInteger

Something like this?

if base.isPower(of: 2) {
  if !self.isPower(of: 2) { return false }
  let baseZeros = base.trailingZeroBitCount
  return trailingZeroBitCount.isMultiple(of: baseZeros)
}
2 Likes