/** * Calculates the subtraction (-) of this rational number and the specified argument. * * <p>This is functionally identical to * <code>this.subtract(BigRational.valueOf(value))</code> * but slightly faster.</p> * * <p>The result has no loss of precision.</p> * * @param value the int value to subtract * @return the resulting rational number */ public BigRational subtract(int value) { if (value == 0) { return(this); } return(subtract(BigInteger.valueOf(value))); }
/** * Calculates the addition (+) of this rational number and the specified argument. * * <p>This is functionally identical to * <code>this.add(BigRational.valueOf(value))</code> * but slightly faster.</p> * * <p>The result has no loss of precision.</p> * * @param value the int value to add * @return the resulting rational number */ public BigRational add(int value) { if (value == 0) { return(this); } return(add(BigInteger.valueOf(value))); }
/** * Calculates the division (/) of this rational number and the specified argument. * * <p>This is functionally identical to * <code>this.divide(BigRational.valueOf(value))</code> * but slightly faster.</p> * * <p>The result has no loss of precision.</p> * * @param value the int value to divide (0 is not allowed) * @return the resulting rational number * @throws ArithmeticException if the argument is 0 (division by zero) */ public BigRational divide(int value) { return(divide(BigInteger.valueOf(value))); }
/** * Calculates the multiplication (*) of this rational number and the specified argument. * * <p>This is functionally identical to * <code>this.multiply(BigRational.valueOf(value))</code> * but slightly faster.</p> * * <p>The result has no loss of precision.</p> * * @param value the int value to multiply * @return the resulting rational number */ public BigRational multiply(int value) { return(multiply(BigInteger.valueOf(value))); }