Java Double Number Round round(double value)

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

Description

Rounds a double to the next nearest integer value.

License

Open Source License

Parameter

Parameter Description
value the double value

Return

the resulting integer value

Declaration

public static  int round(double value) 

Method Source Code

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

public class Main {
    /**/*from   ww w .j a  va 2  s.c o  m*/
     * Rounds a double to the next nearest integer value. The JDK version
     * of it doesn't work properly.
     *
     * @param value the double value
     * @return the resulting integer value
     */
    public static /*@pure@*/ int round(double value) {

        int roundedValue = value > 0 ? (int) (value + 0.5) : -(int) (Math.abs(value) + 0.5);

        return roundedValue;
    }
}

Related

  1. round(double val, int places)
  2. round(double val, long dec)
  3. round(double valor)
  4. round(double value)
  5. round(double value)
  6. round(double value)
  7. round(double value)
  8. round(double value)
  9. round(double value, double decimalplaces)