Java BigDecimal Round valueOfBigDecimalRounding(double d1, int decimalPrecision)

Here you can find the source of valueOfBigDecimalRounding(double d1, int decimalPrecision)

Description

value Of Big Decimal Rounding

License

Open Source License

Declaration

public static BigDecimal valueOfBigDecimalRounding(double d1, int decimalPrecision) 

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 valueOfBigDecimalRounding(double d1, int decimalPrecision) {
        BigDecimal bd = new BigDecimal(d1);
        MathContext mc = new MathContext(decimalPrecision, RoundingMode.HALF_UP);
        return bd.round(mc);
    }//w  ww.ja v a2  s. c om
}

Related

  1. roundOff(final BigDecimal amount)
  2. roundPrice(BigDecimal price, BigDecimal ticksize)
  3. roundTo(final BigDecimal bd, final int numberOfDecPlaces, final int finalScale)
  4. roundToMSDecimal(BigDecimal sourceDecimal)
  5. roundUp1(BigDecimal number)