Here you can find the source of roundUpTo(double in, double del)
Parameter | Description |
---|---|
in | initial value |
del | interval |
public static double roundUpTo(double in, double del)
//package com.java2s; //License from project: Apache License public class Main { /**//w ww . jav a 2s . co m * round in up to the next even multiple of del * @param in initial value * @param del interval * @return next multiple of del >= in */ public static double roundUpTo(double in, double del) { int n = (int) (in / del); double ret = n * del; if (ret == in) return (ret); return (ret + del); } /** * round in up to the next even multiple of del * @param in initial value * @param del interval * @return next multiple of del >= in */ public static int roundUpTo(int in, int del) { int n = (int) (in / del); int ret = n * del; if (ret == in) return (ret); return (ret + del); } }