if (fraction == null) { throw new IllegalArgumentException("The fraction must not be null"); } if (numerator == 0) { return fraction; } if (fraction.numerator == 0) { return this; }  int gcd = greatestCommonDivisor(Math.abs(fraction.denominator), Math.abs(denominator)); int thisResidue = denominator/gcd; int thatResidue = fraction.denominator/gcd; double denominatorValue = Math.abs((double) gcd * thisResidue * thatResidue); double numeratorValue = (double) numerator * thatResidue + fraction.numerator * thisResidue; if (Math.abs(numeratorValue) > Integer.MAX_VALUE || Math.abs(denominatorValue) > Integer.MAX_VALUE) { throw new ArithmeticException("Integer overflow"); } return Fraction.getReducedFraction((int) numeratorValue, (int) denominatorValue);
return addSub(fraction, true );
    public Fraction add(Fraction fraction) {        if (fraction == null) {            throw new IllegalArgumentException("The fraction must not be null");        }        if (numerator == 0) {            return fraction;        }        if (fraction.numerator == 0) {            return this;        }             // Compute lcd explicitly to limit overflow        int gcd = greatestCommonDivisor(Math.abs(fraction.denominator), Math.abs(denominator));        int thisResidue = denominator/gcd;        int thatResidue = fraction.denominator/gcd;        double denominatorValue = Math.abs((double) gcd * thisResidue * thatResidue);        double numeratorValue = (double) numerator * thatResidue + fraction.numerator * thisResidue;        if (Math.abs(numeratorValue) > Integer.MAX_VALUE ||             Math.abs(denominatorValue) > Integer.MAX_VALUE) {                throw new ArithmeticException("Integer overflow");        }        return Fraction.getReducedFraction((int) numeratorValue, (int) denominatorValue);    }