Java Double Number Round round(double number, int digits)

Here you can find the source of round(double number, int digits)

Description

round

License

Open Source License

Declaration

public static double round(double number, int digits) 

Method Source Code

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

public class Main {
    public static double round(double number, int digits) {
        if (digits > 6) {
            return number;
        } else {//w ww  .j a v  a  2  s .  c  o m
            double roundNumber = number;
            roundNumber *= Math.pow(10, digits);
            roundNumber = Math.round(roundNumber);
            roundNumber /= Math.pow(10, digits);
            return roundNumber;
        }
    }
}

Related

  1. round(double num, int precision)
  2. round(double number)
  3. round(double number, double multiplier)
  4. round(double number, int decimal)
  5. round(double number, int digit)
  6. round(double number, int places)
  7. round(double number, int places)
  8. round(double number, int precision)
  9. round(Double number, Integer precision)