Esempio n. 1
0
def _is_uint(value, bits):
    try:
        value, base = strip_and_get_base(value)
        if base == 10 and not value.isdigit(): # "performance" hack
            return False
        return 0 <= int(value, base) <= (2**bits - 1)
    except ValueError:
        return False
Esempio n. 2
0
def _is_uint(value, bits):
    try:
        value, base = strip_and_get_base(value)
        if base == 10 and not value.isdigit():  # "performance" hack
            return False
        return 0 <= int(value, base) <= (2**bits - 1)
    except ValueError:
        return False
Esempio n. 3
0
def _is_int(value, bits):
    try:
        value, base = strip_and_get_base(value)
        return -(2**(bits-1)) <= int(value, base) <= (2**(bits-1) - 1)
    except ValueError:
        return False
Esempio n. 4
0
def _is_int(value, bits):
    try:
        value, base = strip_and_get_base(value)
        return -(2**(bits - 1)) <= int(value, base) <= (2**(bits - 1) - 1)
    except ValueError:
        return False