def exact_log2(number):
    """Find and return an unsigned integer i >= 0 such that ``number == 2**i``. If
  no such integer exists, this function raises ValueError.

  .. NOTE:
      It essentially answers this question:

      "How many times would you have to multiply 2 into itself to
      get the given number?"

  Taken from PyCrypto.

  :param number:
      Unsigned integer.
  :returns:
      An integer i >= 0 such that number == 2**i.
  """
    num = number
    if num <= 0:
        raise ValueError('Cannot compute logarithm of non-positive integer')
    i = 0
    while num:
        if num & 1 and num != 1:
            raise ValueError('No solution could be found')
        i += 1
        num >>= 1
    i -= 1
    return i
