Java Double Number Round round(Double number, Integer precision)

Here you can find the source of round(Double number, Integer precision)

Description

round

License

Open Source License

Declaration

public static Double round(Double number, Integer precision) 

Method Source Code

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

public class Main {
    public static Double round(Double number, Integer precision) {
        Double retObj = null;/*from  www. ja  v a 2s.  co  m*/
        if (number != null) {
            if (precision == null)
                precision = 0;

            Double decimalPlaces = Math.pow(10, precision);
            retObj = (double) Math.round(number * decimalPlaces) / decimalPlaces;

        }
        return retObj;
    }

    public static double round(double number, int precision) {
        double decimalPlaces = Math.pow(10, precision);
        return (double) Math.round(number * decimalPlaces) / decimalPlaces;
    }
}

Related

  1. round(double number, int digit)
  2. round(double number, int digits)
  3. round(double number, int places)
  4. round(double number, int places)
  5. round(double number, int precision)
  6. round(Double ret, Integer doublePrecision)
  7. round(double round, int decimal, int ceilOrFloor)
  8. round(double Rpred[][])
  9. Round(double Rval, int Rpl)