Java Double Number Round roundDouble(double val, int precision)

Here you can find the source of roundDouble(double val, int precision)

Description

roundDouble.

License

Open Source License

Parameter

Parameter Description
val double
precision int

Return

Double

Declaration

public static Double roundDouble(double val, int precision) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from w  w w .  ja v  a2s.  c  o m*/
     * roundDouble.
     * 
     * @param val double
     * @param precision int
     * @return Double
     */
    public static Double roundDouble(double val, int precision) {

        double factor = Math.pow(10, precision);
        return Math.floor(val * factor + 0.5) / factor;
    }
}

Related

  1. roundDouble(double d, int place)
  2. roundDouble(double d, int places)
  3. roundDouble(double num, int precision)
  4. roundDouble(double number, int precision)
  5. roundDouble(double pDouble, int pPlaces)
  6. roundDouble(double value)
  7. roundDouble(double value, int afterDecimalPoint)
  8. roundDouble3(double r)
  9. roundDoubleDownTo(double value, double steps)