Here you can find the source of round(double n)
public static int round(double n)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w.j a v a2 s .c om * Round to the nearest integer.<br> * This is different from Math.round() for negative number. * i.e., 2.5->3, 2.499->2, -1.499->-1, -1.5-->-2 */ public static int round(double n) { return (int) ((n > 0 ? 0.5 : -0.5) + n); } }