Java BigDecimal Divide divide(BigDecimal number1, BigDecimal number2, int decimalPlaces)

Here you can find the source of divide(BigDecimal number1, BigDecimal number2, int decimalPlaces)

Description

divide

License

Apache License

Declaration

private static BigDecimal divide(BigDecimal number1, BigDecimal number2, int decimalPlaces) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;

public class Main {
    private static final MathContext mathContext = MathContext.DECIMAL128;
    private static final RoundingMode roundingMode = RoundingMode.HALF_UP;

    private static BigDecimal divide(BigDecimal number1, BigDecimal number2, int decimalPlaces) {
        return number1.divide(number2, mathContext).setScale(decimalPlaces, roundingMode);
    }//from w  ww. ja  v  a 2  s . c om
}

Related

  1. divide(BigDecimal dividend, BigDecimal divisor)
  2. divide(BigDecimal dividend, BigDecimal divisor, int scale)
  3. divide(BigDecimal left, BigDecimal right)
  4. divide(BigDecimal num1, BigDecimal num2, int scale, int mode)
  5. divide(BigDecimal num1, BigDecimal num2, int scale, int roundingMode)
  6. divide(BigDecimal numerator, BigDecimal denominator)
  7. divide(BigDecimal one, BigDecimal another)
  8. divide(BigDecimal op1, int op2, int precision)
  9. divide(BigDecimal v1, BigDecimal v2)