Here you can find the source of floor(final double num)
Parameter | Description |
---|---|
num | number to round down. |
public static int floor(final double num)
//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)); } }