Here you can find the source of floor(final float val)
Parameter | Description |
---|---|
val | Value to floor |
public static int floor(final float val)
//package com.java2s; /**/* w w w.j av a2 s .c o m*/ * Copyright (c) 2008-2012 Ardor Labs, Inc. * * This file is part of Ardor3D. * * Ardor3D is free software: you can redistribute it and/or modify it * under the terms of its license which may be found in the accompanying * LICENSE file or at <http://www.ardor3d.com/LICENSE>. */ public class Main { /** * Faster floor function. Does not handle NaN and Infinity. (Not handled when doing Math.floor and just casting * anyways, so question is if we want to handle it or not) * * @param val * Value to floor * @return Floored int value */ public static int floor(final float val) { final int intVal = (int) val; return val < 0 ? val == intVal ? intVal : intVal - 1 : intVal; } /** * Faster floor function. Does not handle NaN and Infinity. (Not handled when doing Math.floor and just casting * anyways, so question is if we want to handle it or not) * * @param val * Value to floor * @return Floored long value */ public static long floor(final double val) { final long longVal = (long) val; return val < 0 ? val == longVal ? longVal : longVal - 1 : longVal; } }