negate() public method

public negate ( ) : global::java.math.BigDecimal
return global::java.math.BigDecimal
Exemplo n.º 1
0
        /**
         * Calculates the reciprocal of this complex number using the specified {@link MathContext}.
         *
         * <p>This methods <strong>does not</strong> modify this instance.</p>
         *
         * @param mathContext the {@link MathContext} used to calculate the result
         * @return the calculated {@link BigComplex} result
         */
        public BigComplex reciprocal(MathContext mathContext)
        {
            BigDecimal scale = absSquare(mathContext);

            return(valueOf(
                       re.divide(scale, mathContext),
                       im.negate().divide(scale, mathContext)));
        }
Exemplo n.º 2
0
        /**
         * Negates this rational number (inverting the sign).
         *
         * <p>The result has no loss of precision.</p>
         *
         * <p>Examples:</p>
         * <ul>
         * <li><code>BigRational.valueOf(3.5).negate()</code> returns <code>BigRational.valueOf(-3.5)</code></li>
         * </ul>
         *
         * @return the negated rational number
         */
        public BigRational negate()
        {
            if (isZero())
            {
                return(this);
            }

            return(of(numerator.negate(), denominator));
        }
Exemplo n.º 3
0
        public BigRational(BigDecimal num, BigDecimal denom)
        {
            BigDecimal n = num;
            BigDecimal d = denom;

            if (d.signum() == 0)
            {
                throw new ArithmeticException("Divide by zero");
            }

            if (d.signum() < 0)
            {
                n = n.negate();
                d = d.negate();
            }

            numerator   = n;
            denominator = d;
        }
Exemplo n.º 4
0
 /**
  * Calculates the negation {@code -a - bi} of this complex number.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex negate()
 {
     return(valueOf(re.negate(), im.negate()));
 }