

def bit_size(num):
    "\n    Number of bits needed to represent a integer excluding any prefix\n    0 bits.\n\n    As per definition from http://wiki.python.org/moin/BitManipulation and\n    to match the behavior of the Python 3 API.\n\n    Usage::\n    \n        >>> bit_size(1023)\n        10\n        >>> bit_size(1024)\n        11\n        >>> bit_size(1025)\n        11\n\n    :param num:\n        Integer value. If num is 0, returns 0. Only the absolute value of the\n        number is considered. Therefore, signed integers will be abs(num)\n        before the number's bit length is determined.\n    :returns:\n        Returns the number of bits in the integer.\n    "
    if (num == 0):
        return 0
    if (num < 0):
        num = (- num)
    (num & 1)
    hex_num = ('%x' % num)
    return (((len(hex_num) - 1) * 4) + {
        '0': 0,
        '1': 1,
        '2': 2,
        '3': 2,
        '4': 3,
        '5': 3,
        '6': 3,
        '7': 3,
        '8': 4,
        '9': 4,
        'a': 4,
        'b': 4,
        'c': 4,
        'd': 4,
        'e': 4,
        'f': 4,
    }[hex_num[0]])

dataset/ETHPy150Open CouchPotato/CouchPotatoServer/libs/rsa/common.py bit_size/original