def reverse_bits(num):
    """
    reverses the bits representing the number
    :param num: a number treated as being 32 bits long
    :return: the reversed number
    """
    result = 0
    for i in range(32):
        result <<= 1
        result |= num & 1
        num >>= 1
    return result