double numeratorValue = (double) numerator * fraction.numerator; double denominatorValue = (double) denominator * fraction.denominator; if (Math.abs(numeratorValue) > Integer.MAX_VALUE || Math.abs(denominatorValue) > Integer.MAX_VALUE) { throw new ArithmeticException("Integer overflow"); } return getReducedFraction((int) numeratorValue, (int) denominatorValue);
int d1 = greatestCommonDivisor(numerator, fraction.denominator); int d2 = greatestCommonDivisor(fraction.numerator, denominator); return getReducedFraction (mulAndCheck(numerator/d1, fraction.numerator/d2), mulPosAndCheck(denominator/d2, fraction.denominator/d1));
    public Fraction multiplyBy(Fraction fraction) {        if (fraction == null) {            throw new IllegalArgumentException("The fraction must not be null");        }        if (numerator == 0 || fraction.numerator == 0) {            return ZERO;        }        double numeratorValue = (double) numerator * fraction.numerator;        double denominatorValue = (double) denominator * fraction.denominator;        if (Math.abs(numeratorValue) > Integer.MAX_VALUE ||             Math.abs(denominatorValue) > Integer.MAX_VALUE) {                throw new ArithmeticException("Integer overflow");        }        return getReducedFraction((int) numeratorValue, (int) denominatorValue);    }