def _randint_arg_check(low, high, endpoint, lower_bound, upper_bound):
    """
    Check that low and high are within the bounds
    for the given datatype.
    """

    if low < lower_bound:
        raise ValueError("low is out of bounds")

    # This is being done to avoid high being accidentally
    # casted to int64/32 while subtracting 1 before
    # checking bounds, avoids overflow.
    if high > 0:
        high = uint64(high)
        if not endpoint:
            high -= uint64(1)
        upper_bound = uint64(upper_bound)
        if low > 0:
            low = uint64(low)
        if high > upper_bound:
            raise ValueError("high is out of bounds")
        if low > high:  # -1 already subtracted, closed interval
            raise ValueError("low is greater than high in given interval")
    else:
        if high > upper_bound:
            raise ValueError("high is out of bounds")
        if low > high:  # -1 already subtracted, closed interval
            raise ValueError("low is greater than high in given interval")

    Check that low and high are within the bounds
    for the given datatype.
    
numba/np/random/old_random_methods.py