equals() public method

public equals ( java arg0 ) : bool
arg0 java
return bool
示例#1
0
 /**
  * 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 {@link BigInteger} to subtract
  * @return the resulting rational number
  */
 public BigRational subtract(BigInteger value)
 {
     if (value.equals(BigInteger.ZERO))
     {
         return(this);
     }
     return(subtract(new BigDecimal(value)));
 }
示例#2
0
        /**
         * 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 {@link BigInteger} to divide (0 is not allowed)
         * @return the resulting rational number
         * @throws ArithmeticException if the argument is 0 (division by zero)
         */
        public BigRational divide(BigInteger value)
        {
            if (value.equals(BigInteger.ONE))
            {
                return(this);
            }

            return(divide(new BigDecimal(value)));
        }
示例#3
0
        /**
         * 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 {@link BigInteger} to multiply
         * @return the resulting rational number
         */
        public BigRational multiply(BigInteger value)
        {
            if (isZero() || value.signum() == 0)
            {
                return(ZERO);
            }
            if (equals(ONE))
            {
                return(valueOf(value));
            }
            if (value.equals(BigInteger.ONE))
            {
                return(this);
            }

            return(multiply(new BigDecimal(value)));
        }