Here you can find the source of round(double value)
Parameter | Description |
---|---|
value | the double value |
public static int round(double value)
//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; } }