/** * <p>Adds the value of this fraction to another, returning the result in reduced form. * The algorithm follows Knuth, 4.5.1.</p> * * @param fraction the fraction to add, must not be <code>null</code> * @return a <code>Fraction</code> instance with the resulting values * @throws IllegalArgumentException if the fraction is <code>null</code> * @throws ArithmeticException if the resulting numerator or denominator exceeds * <code>Integer.MAX_VALUE</code> */ public Fraction add(Fraction fraction) { return addSub(fraction, true /* add */); }
/** * <p>Subtracts the value of another fraction from the value of this one, * returning the result in reduced form.</p> * * @param fraction the fraction to subtract, must not be <code>null</code> * @return a <code>Fraction</code> instance with the resulting values * @throws IllegalArgumentException if the fraction is <code>null</code> * @throws ArithmeticException if the resulting numerator or denominator * cannot be represented in an <code>int</code>. */ public Fraction subtract(Fraction fraction) { return addSub(fraction, false /* subtract */); }
/** * <p>Subtracts the value of another fraction from the value of this one, * returning the result in reduced form.</p> * * @param fraction the fraction to subtract, must not be <code>null</code> * @return a <code>Fraction</code> instance with the resulting values * @throws IllegalArgumentException if the fraction is <code>null</code> * @throws ArithmeticException if the resulting numerator or denominator * cannot be represented in an <code>int</code>. */ public Fraction subtract(Fraction fraction) { return addSub(fraction, false /* subtract */); }
/** * <p>Adds the value of this fraction to another, returning the result in reduced form. * The algorithm follows Knuth, 4.5.1.</p> * * @param fraction the fraction to add, must not be <code>null</code> * @return a <code>Fraction</code> instance with the resulting values * @throws IllegalArgumentException if the fraction is <code>null</code> * @throws ArithmeticException if the resulting numerator or denominator exceeds * <code>Integer.MAX_VALUE</code> */ public Fraction add(Fraction fraction) { return addSub(fraction, true /* add */); }
/** * <p>Subtracts the value of another fraction from the value of this one, * returning the result in reduced form.</p> * * @param fraction the fraction to subtract, must not be <code>null</code> * @return a <code>Fraction</code> instance with the resulting values * @throws IllegalArgumentException if the fraction is <code>null</code> * @throws ArithmeticException if the resulting numerator or denominator * cannot be represented in an <code>int</code>. */ public Fraction subtract(Fraction fraction) { return addSub(fraction, false /* subtract */); }
/** * <p>Adds the value of this fraction to another, returning the result in reduced form. * The algorithm follows Knuth, 4.5.1.</p> * * @param fraction the fraction to add, must not be <code>null</code> * @return a <code>Fraction</code> instance with the resulting values * @throws IllegalArgumentException if the fraction is <code>null</code> * @throws ArithmeticException if the resulting numerator or denominator exceeds * <code>Integer.MAX_VALUE</code> */ public Fraction add(Fraction fraction) { return addSub(fraction, true /* add */); }
/** * <p>Adds the value of this fraction to another, returning the result in reduced form. * The algorithm follows Knuth, 4.5.1.</p> * * @param fraction the fraction to add, must not be <code>null</code> * @return a <code>Fraction</code> instance with the resulting values * @throws IllegalArgumentException if the fraction is <code>null</code> * @throws ArithmeticException if the resulting numerator or denominator exceeds * <code>Integer.MAX_VALUE</code> */ public Fraction add(Fraction fraction) { return addSub(fraction, true /* add */); }
/** * <p>Adds the value of this fraction to another, returning the result in reduced form. * The algorithm follows Knuth, 4.5.1.</p> * * @param fraction the fraction to add, must not be <code>null</code> * @return a <code>Fraction</code> instance with the resulting values * @throws IllegalArgumentException if the fraction is <code>null</code> * @throws ArithmeticException if the resulting numerator or denominator exceeds * <code>Integer.MAX_VALUE</code> */ public Fraction add(Fraction fraction) { return addSub(fraction, true /* add */); }
/** * <p>Subtracts the value of another fraction from the value of this one, * returning the result in reduced form.</p> * * @param fraction the fraction to subtract, must not be <code>null</code> * @return a <code>Fraction</code> instance with the resulting values * @throws IllegalArgumentException if the fraction is <code>null</code> * @throws ArithmeticException if the resulting numerator or denominator * cannot be represented in an <code>int</code>. */ public Fraction subtract(Fraction fraction) { return addSub(fraction, false /* subtract */); }
/** * <p>Adds the value of this fraction to another, returning the result in reduced form. * The algorithm follows Knuth, 4.5.1.</p> * * @param fraction the fraction to add, must not be <code>null</code> * @return a <code>Fraction</code> instance with the resulting values * @throws IllegalArgumentException if the fraction is <code>null</code> * @throws ArithmeticException if the resulting numerator or denominator exceeds * <code>Integer.MAX_VALUE</code> */ public Fraction add(Fraction fraction) { return addSub(fraction, true /* add */); }
/** * <p>Subtracts the value of another fraction from the value of this one, * returning the result in reduced form.</p> * * @param fraction the fraction to subtract, must not be <code>null</code> * @return a <code>Fraction</code> instance with the resulting values * @throws IllegalArgumentException if the fraction is <code>null</code> * @throws ArithmeticException if the resulting numerator or denominator * cannot be represented in an <code>int</code>. */ public Fraction subtract(Fraction fraction) { return addSub(fraction, false /* subtract */); }
/** * <p>Subtracts the value of another fraction from the value of this one, * returning the result in reduced form.</p> * * @param fraction the fraction to subtract, must not be <code>null</code> * @return a <code>Fraction</code> instance with the resulting values * @throws IllegalArgumentException if the fraction is <code>null</code> * @throws ArithmeticException if the resulting numerator or denominator * cannot be represented in an <code>int</code>. */ public Fraction subtract(Fraction fraction) { return addSub(fraction, false /* subtract */); }