Here you can find the source of roundUpToNearest(double number, double nearest)
public static double roundUpToNearest(double number, double nearest)
//package com.java2s; /**//from w ww.j av a 2s . c om * NumericImpl contains logic for numeric data. This implementation is referred to YUI's NumericImpl.js which license under * BSD License. - http://yuilibrary.com/license/ * @author jumperchen * */ public class Main { public static double roundUpToNearest(double number, double nearest) { return Math.ceil(roundToPrecision(number / nearest, 10)) * nearest; } public static double roundToPrecision(double number, int precision) { double decimalPlaces = Math.pow(10, precision); return Math.round(decimalPlaces * number) / decimalPlaces; } }