public static int safe2Int(long value) {
        if (value > Integer.MAX_VALUE || value < Integer.MIN_VALUE) {
            throw new IndexOutOfBoundsException("value = " + value + ", which is too large to fit in an int");
        }
        return (int) value;
    }
Utility to make common conversions safe

@author baldersheim
vespajlib/src/main/java/com/yahoo/tensor/impl/Convert.java