Java Double Number Round round(double d)

Here you can find the source of round(double d)

Description

Round a double

License

Open Source License

Parameter

Parameter Description
d - the double to round

Return

- the rounded double as integer

Declaration

public static int round(double d) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from   www . j  av a  2 s  . co m*/
     * Round a double
     *
     * @param d - the double to round
     * @return - the rounded double as integer
     */
    public static int round(double d) {
        int i = (int) d;
        double result = d - i;
        if (result < 0.5D)
            return i;
        return i + 1;
    }
}

Related

  1. round(double amt, int digits)
  2. round(double d)
  3. round(double d)
  4. round(double d)
  5. round(double d)
  6. round(double d)
  7. round(double d)
  8. round(double d)
  9. round(double d, int decimalPlacesRequired)