Java Number Round roundTo(double num, int dp)

Here you can find the source of roundTo(double num, int dp)

Description

round To

License

Open Source License

Declaration

public static double roundTo(double num, int dp) 

Method Source Code

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

public class Main {
    public static double roundTo(double num, int dp) {
        int dpM = (int) Math.pow(10, dp);
        return Math.round(num * dpM) / dpM;
    }/*from   w w w  .ja v a  2 s . c om*/
}

Related

  1. roundTime24h(final long defaultUnitValue)
  2. roundTimeStamp(long tstamp)
  3. roundTimeValue(final float defaultUnitValue, final boolean is24HourFormatting)
  4. roundTo(double aValue, int aDigits)
  5. roundTo(double d, int n)
  6. roundTo(double val, double prec)
  7. roundTo(final double VALUE, final double TARGET)
  8. roundTo(float number, int base)
  9. roundTo(float number, int numPlaces)