Java Double Number Round roundDecimals(double d, int decimalPlaces)

Here you can find the source of roundDecimals(double d, int decimalPlaces)

Description

round Decimals

License

Open Source License

Declaration

public static double roundDecimals(double d, int decimalPlaces) 

Method Source Code

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

public class Main {
    public static double roundDecimals(double d, int decimalPlaces) {
        int j = (int) (d * Math.pow(10, decimalPlaces));
        return j / Math.pow(10, decimalPlaces);
    }//from  w  w w .  j  av  a 2  s .c o  m

    public static double roundDecimals(double d) {
        return roundDecimals(d, 2);
    }
}

Related

  1. roundAwayFromZero(double num)
  2. roundBig(double d)
  3. roundDec(float num, int dec)
  4. roundDecimal(Double value)
  5. roundDecimal(double x, int d)
  6. roundDecimals(double x, int decimals)
  7. roundDiv(double a, double b)
  8. roundDouble(double d)
  9. roundDouble(double d)