Java Double Number Round round(double value, int decimals)

Here you can find the source of round(double value, int decimals)

Description

round

License

Open Source License

Declaration

public static double round(double value, int decimals) 

Method Source Code

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

public class Main {
    private static final int DEFAULT_DECIMAL_PLACES = 3;

    public static double round(double value, int decimals) {
        int base = (int) Math.pow(10, decimals);

        return Math.floor(value * base) / base;
    }/*  w  ww  .  j  a va 2 s.  co m*/

    public static double round(double value) {
        return round(value, DEFAULT_DECIMAL_PLACES);
    }
}

Related

  1. round(double value, int decimal)
  2. round(double value, int decimal)
  3. round(double value, int decimalPlace)
  4. round(double value, int decimalPlaces)
  5. round(double value, int decimalPlaces)
  6. round(double value, int decimals)
  7. round(double value, int exponent)
  8. round(double value, int nbDigits)
  9. round(double value, int numberOfDecimalPlaces)