Java Double Number Round roundDecimal(Double value)

Here you can find the source of roundDecimal(Double value)

Description

round Decimal

License

Open Source License

Declaration

public static Double roundDecimal(Double value) 

Method Source Code

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

public class Main {
    public static final int DEFAULT_DECIMALS = 3;

    public static Double roundDecimal(Double value) {
        return roundDecimal(value, DEFAULT_DECIMALS);
    }/*from w ww.j  a v  a2s.  c o  m*/

    public static Double roundDecimal(Double value, int decimals) {
        double coeficient = Math.pow(10, decimals);
        return Math.round(value * coeficient) / coeficient;
    }
}

Related

  1. roundAtDecimals(double number, int deci)
  2. roundAway(double d)
  3. roundAwayFromZero(double num)
  4. roundBig(double d)
  5. roundDec(float num, int dec)
  6. roundDecimal(double x, int d)
  7. roundDecimals(double d, int decimalPlaces)
  8. roundDecimals(double x, int decimals)
  9. roundDiv(double a, double b)