Java Ceil ceil(final double num)

Here you can find the source of ceil(final double num)

Description

Round up given number.

License

Open Source License

Parameter

Parameter Description
num number to round up.

Return

rounded number.

Declaration

public static int ceil(final double num) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//w  w  w .j  av  a2  s  . c  o m
     * Round up given number.
     *
     * @param num number to round up.
     *
     * @return rounded number.
     *
     * @see Math#round(double)
     */
    public static int ceil(final double num) {
        final int ceil = (int) num;
        return (ceil == num) ? ceil : ((num > 0) ? (ceil + 1) : ceil);
    }

    /**
     * Round up given number.
     *
     * @param num number to round up.
     *
     * @return rounded number.
     *
     * @see Math#round(double)
     */
    public static int ceil(final float num) {
        final int ceil = (int) num;
        return (ceil == num) ? ceil : ((num > 0) ? (ceil + 1) : ceil);
    }
}

Related

  1. ceil(double x)
  2. ceil(double x)
  3. ceil(double x, double y)
  4. ceil(double[] array)
  5. ceil(final double num)
  6. ceil(float f)
  7. ceil(float f)
  8. ceil(float f)
  9. ceil(float floatNumber)