Java Double Number Round round(double d, int i)

Here you can find the source of round(double d, int i)

Description

round

License

Apache License

Declaration

public static double round(double d, int i) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static double round(double d, int i) {
        long powerTen = 1;
        for (int x = 0; x < i; x++) {
            powerTen *= 10;/*  w w  w.j av  a 2 s .  c o  m*/
        }
        return ((double) Math.round(d * powerTen)) / powerTen;
    }
}

Related

  1. round(double d)
  2. round(double d)
  3. round(double d)
  4. round(double d, int decimalPlacesRequired)
  5. round(double d, int decimals)
  6. round(double d, int numDecimal)
  7. round(double d, int p)
  8. round(double d, int precision)
  9. Round(double d, int Rpl)