Java BigDecimal Round roundHalfUp2Scale(BigDecimal value)

Here you can find the source of roundHalfUp2Scale(BigDecimal value)

Description

round Half Up Scale

License

Open Source License

Declaration

public static Double roundHalfUp2Scale(BigDecimal value) 

Method Source Code


//package com.java2s;
import java.math.BigDecimal;

public class Main {
    public static Double roundHalfUp2Scale(BigDecimal value) {
        if (value == null)
            return null;
        BigDecimal bd = value.setScale(2, BigDecimal.ROUND_HALF_UP);
        return bd.doubleValue();
    }//from   ww  w.ja va  2  s  .  c  o m

    public static BigDecimal roundHalfUp2Scale(Double value) {
        if (value == null)
            return null;
        String sval = String.valueOf(value);
        BigDecimal bd = new BigDecimal(sval);
        return bd.setScale(2, BigDecimal.ROUND_HALF_UP);
    }
}

Related

  1. roundDecimal(Object value)
  2. roundDecimals(Float d)
  3. roundDoubleAsBigDecimal(double d, int numberOfDecimals)
  4. roundDown(BigDecimal a)
  5. rounded(BigDecimal amount)
  6. roundImpl(final BigDecimal number, final int minFractionDigits, final int maxFractionDigits, final RoundingMode mode)
  7. roundingError(final BigDecimal dividend, final BigDecimal divisor, final int roundingMode)
  8. roundOff(final BigDecimal amount)
  9. roundPrice(BigDecimal price, BigDecimal ticksize)