Java examples for java.lang:Math Operation
rounds to next int
//package com.java2s; import java.math.BigDecimal; public class Main { /**/* w w w . j a v a 2s .c om*/ * rounds to next int * * @param val * @param decPlaces * @return */ public static double roundUp(double val, int decPlaces) { BigDecimal bd = new BigDecimal(val); bd = bd.setScale(decPlaces, BigDecimal.ROUND_UP); val = bd.doubleValue(); return val; } /** * rounds to next int * * @param val * @return */ public static double roundUp(double val) { BigDecimal bd = new BigDecimal(val); bd = bd.setScale(0, BigDecimal.ROUND_UP); val = bd.doubleValue(); return val; } }