Here you can find the source of RoundUp(final T number)
Parameter | Description |
---|---|
number | number to be handled. |
public static <T extends Number> long RoundUp(final T number)
//package com.java2s; //License from project: Apache License public class Main { /**/*from w ww . j a va 2 s . c o m*/ * Returns a long number by round up with specify number.<br> * Returns 0 if number == null.<br> * e.g: average is 3.5, then return 4. * * @param number * number to be handled. * @return a long number by round up with specify number. */ public static <T extends Number> long RoundUp(final T number) { if (number == null) { return 0; } double value = number.doubleValue(); if (value % 1 == 0) { return (long) value; } else { return (long) (value + 1); } } }