Java Double Number Round Round(double d, int Rpl)

Here you can find the source of Round(double d, int Rpl)

Description

rounds a number to RPL places

License

LGPL

Parameter

Parameter Description
d the double to be rounded
Rpl the number of places to round to

Return

the rounded double

Declaration

public static float Round(double d, int Rpl) 

Method Source Code

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

public class Main {
    /**//from w ww  .j a v a  2s  .  c  o m
     * rounds a number to RPL places
     * 
     * @param d
     *            the double to be rounded
     * @param Rpl
     *            the number of places to round to
     * @return the rounded double
     */
    public static float Round(double d, int Rpl) {
        float p = (float) Math.pow(10, Rpl);
        d = d * p;
        float tmp = Math.round(d);
        return (float) tmp / p;
    }
}

Related

  1. round(double d, int decimals)
  2. round(double d, int i)
  3. round(double d, int numDecimal)
  4. round(double d, int p)
  5. round(double d, int precision)
  6. round(double dValue)
  7. round(double input)
  8. round(double input, double step)
  9. round(double n)