Code example for BigInteger

Methods: compareTo, longValue

0
    /** 
     * convert a PyLong into a long between Long.MIN_VALUE and Long.MAX_VALUE 
     */ 
    private static long getLong(PyLong pyLong) {
        BigInteger value = pyLong.getValue();
        if (value.compareTo(MAX_LONG_BIGINTEGER) > 0) {
            return Long.MAX_VALUE;
        } 
        if (value.compareTo(MIN_LONG_BIGINTEGER) < 0) {
            return Long.MIN_VALUE;
        } 
        return value.longValue();
    } 
 
    private static boolean isIntegral(double v) {
        return ceil(v) - v == ZERO;
    } 
 
    private static boolean isOdd(double v) {
        return isIntegral(v) && v % TWO != ZERO;
    }