Here you can find the source of roundToNearest(double number)
public static double roundToNearest(double number)
//package com.java2s; //License from project: Open Source License public class Main { public static double roundToNearest(double number) { if ((int) (number + .5) >= (int) (number)) return (int) number + 1; return (int) number; }/*from w w w. j a v a 2 s . co m*/ }