Java Double Number Round round(double valueToRound, int numberOfDecimalPlaces)

Here you can find the source of round(double valueToRound, int numberOfDecimalPlaces)

Description

round

License

Open Source License

Declaration

public static double round(double valueToRound, int numberOfDecimalPlaces) 

Method Source Code

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

public class Main {
    public static double round(double valueToRound, int numberOfDecimalPlaces) {
        if (Double.isNaN(valueToRound))
            return Double.NaN;
        double multipicationFactor = Math.pow(10, numberOfDecimalPlaces);
        double interestedInZeroDPs = valueToRound * multipicationFactor;
        return Math.round(interestedInZeroDPs) / multipicationFactor;

    }/*from www  . j a va  2s  . c  om*/
}

Related

  1. round(double value, int precision)
  2. round(double value, int precision)
  3. round(double value, int precision)
  4. round(double value, int roundingFactor)
  5. round(double value, int scalar, int standard)
  6. round(double valueToTruncate, int requiredDecimalPlaces)
  7. round(double what, int howmuch)
  8. round(double x)
  9. round(double x)