multiply() public method

public multiply ( java arg0 ) : global::java.math.BigDecimal
arg0 java
return global::java.math.BigDecimal
Beispiel #1
0
        /**
         * Returns a complex number with the specified polar {@link BigDecimal} radius and angle using the specified {@link MathContext}.
         *
         * @param radius the {@link BigDecimal} radius of the polar representation
         * @param angle the {@link BigDecimal} angle in radians of the polar representation
         * @param mathContext the {@link MathContext} used to calculate the result
         * @return the complex number
         */
        public static BigComplex valueOfPolar(BigDecimal radius, BigDecimal angle, MathContext mathContext)
        {
            if (radius.signum() == 0)
            {
                return(ZERO);
            }

            return(valueOf(
                       radius.multiply(BigDecimalMath.cos(angle, mathContext), mathContext),
                       radius.multiply(BigDecimalMath.sin(angle, mathContext), mathContext)));
        }
Beispiel #2
0
        /**
         * Calculates the addition (+) of this rational number and the specified argument.
         *
         * <p>The result has no loss of precision.</p>
         *
         * @param value the rational number to add
         * @return the resulting rational number
         */
        public BigRational add(BigRational value)
        {
            if (denominator.equals(value.denominator))
            {
                return(of(numerator.add(value.numerator), denominator));
            }

            BigDecimal n = numerator.multiply(value.denominator).add(value.numerator.multiply(denominator));
            BigDecimal d = denominator.multiply(value.denominator);

            return(of(n, d));
        }
Beispiel #3
0
 private BigRational subtract(BigDecimal value)
 {
     return(of(numerator.subtract(value.multiply(denominator)), denominator));
 }
Beispiel #4
0
 private BigRational add(BigDecimal value)
 {
     return(of(numerator.add(value.multiply(denominator)), denominator));
 }
Beispiel #5
0
 /**
  * Calculates the multiplication of the given complex value to this complex number.
  *
  * <p>This methods <strong>does not</strong> modify this instance.</p>
  *
  * @param value the {@link BigComplex} value to multiply
  * @return the calculated {@link BigComplex} result
  */
 public BigComplex multiply(BigComplex value)
 {
     return(valueOf(
                re.multiply(value.re).subtract(im.multiply(value.im)),
                re.multiply(value.im).add(im.multiply(value.re))));
 }