Ejemplo n.º 1
0
        /**
         * Returns a new {@code BigDecimal} whose value is {@code this / divisor}.
         * As scale of the result the parameter {@code scale} is used. If rounding
         * is required to meet the specified scale, then the specified rounding mode
         * {@code roundingMode} is applied.
         *
         * @param divisor
         *            value by which {@code this} is divided.
         * @param scale
         *            the scale of the result returned.
         * @param roundingMode
         *            rounding mode to be used to round the result.
         * @return {@code this / divisor} rounded according to the given rounding
         *         mode.
         * @throws NullPointerException
         *             if {@code divisor == null} or {@code roundingMode == null}.
         * @throws ArithmeticException
         *             if {@code divisor == 0}.
         * @throws ArithmeticException
         *             if {@code roundingMode == RoundingMode.UNNECESSAR}Y and
         *             rounding is necessary according to the given scale and given
         *             precision.
         */

        public static BigDecimal Divide(BigDecimal a, BigDecimal b, int scale, RoundingMode roundingMode)
        {
            return(BigDecimalMath.Divide(a, b, scale, roundingMode));
        }
Ejemplo n.º 2
0
        /**
         * Returns a new {@code BigDecimal} whose value is {@code this / divisor}.
         * The result is rounded according to the passed context {@code mc}. If the
         * passed math context specifies precision {@code 0}, then this call is
         * equivalent to {@code this.divide(divisor)}.
         *
         * @param divisor
         *            value by which {@code this} is divided.
         * @param mc
         *            rounding mode and precision for the result of this operation.
         * @return {@code this / divisor}.
         * @throws NullPointerException
         *             if {@code divisor == null} or {@code mc == null}.
         * @throws ArithmeticException
         *             if {@code divisor == 0}.
         * @throws ArithmeticException
         *             if {@code mc.getRoundingMode() == UNNECESSARY} and rounding
         *             is necessary according {@code mc.getPrecision()}.
         */

        public static BigDecimal Divide(BigDecimal a, BigDecimal b, MathContext context)
        {
            return(BigDecimalMath.Divide(a, b, context));
        }
Ejemplo n.º 3
0
 /**
  * Returns a new {@code BigDecimal} whose value is {@code this / divisor}.
  * The scale of the result is the difference of the scales of {@code this}
  * and {@code divisor}. If the exact result requires more digits, then the
  * scale is adjusted accordingly. For example, {@code 1/128 = 0.0078125}
  * which has a scale of {@code 7} and precision {@code 5}.
  *
  * @param divisor
  *            value by which {@code this} is divided.
  * @return {@code this / divisor}.
  * @throws NullPointerException
  *             if {@code divisor == null}.
  * @throws ArithmeticException
  *             if {@code divisor == 0}.
  * @throws ArithmeticException
  *             if the result cannot be represented exactly.
  */
 public static BigDecimal Divide(BigDecimal a, BigDecimal b)
 {
     return(BigDecimalMath.Divide(a, b));
 }