Java BigDecimal Divide divide(BigDecimal op1, int op2, int precision)

Here you can find the source of divide(BigDecimal op1, int op2, int precision)

Description

divide

License

Open Source License

Declaration

public static BigDecimal divide(BigDecimal op1, int op2, int precision) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static BigDecimal divide(BigDecimal op1, int op2, int precision) {
        MathContext roundVal = new MathContext(precision, RoundingMode.HALF_UP);
        return op1.divide(new BigDecimal(op2)).round(roundVal);
    }/*from w  w  w.j  a v  a  2  s. c  o m*/
}

Related

  1. divide(BigDecimal num1, BigDecimal num2, int scale, int mode)
  2. divide(BigDecimal num1, BigDecimal num2, int scale, int roundingMode)
  3. divide(BigDecimal number1, BigDecimal number2, int decimalPlaces)
  4. divide(BigDecimal numerator, BigDecimal denominator)
  5. divide(BigDecimal one, BigDecimal another)
  6. divide(BigDecimal v1, BigDecimal v2)
  7. divide(final BigDecimal amount, final BigDecimal divideBy, final int scale)
  8. divide(long res, BigDecimal value)
  9. divide(Vector v, BigDecimal magnitude)