Java floor floor(final double num)

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

Description

Round down given number.

License

Open Source License

Parameter

Parameter Description
num number to round down.

Return

rounded number.

Declaration

public static int floor(final double num) 

Method Source Code

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

public class Main {
    /**//www. ja  v a 2  s.  co m
     * Round down given number.
     *
     * @param num number to round down.
     *
     * @return rounded number.
     *
     * @see Math#round(double)
     */
    public static int floor(final double num) {
        final int floor = (int) num;
        return (floor == num) ? floor : ((num > 0) ? floor : (floor - 1));
    }

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

Related

  1. floor(double x)
  2. floor(double x)
  3. floor(double x)
  4. floor(double x, double y)
  5. floor(double[] array)
  6. floor(final float val)
  7. floor(final float x)
  8. floor(float a)
  9. floor(float f)