Java Utililty Methods floor

List of utility methods to do floor

Description

The list of methods to do floor are organized into topic(s).

Method

intfloorPositive(float value)
Returns the largest integer less than or equal to the specified float.
return (int) value;
floatfloorPot(float value)
floor Pot
float returnValue = 0.0f;
for (float newValue = 2.0f; newValue < value; newValue *= 2.0f) {
    returnValue = newValue;
return returnValue;
intfloorPOT(int n)
floor POT
return ceilMaskPOT(n) + 1 >>> 1;
intfloorPowerOf2(final int n)
Computes the floor power of 2 within the range [1, 2^30].
if (n <= 1) {
    return 1;
return Integer.highestOneBit(n);
intfloorPowerOf2(final int x)
Rounds down the value to the nearest lower power^2 value.
return (int) Math.pow(2, (int) (Math.log(x) / LOG2));
intfloorPowerOf2(int n)
Computes the floor power of 2 within the range [1, 2^30].
if (n <= 1) {
    return 1;
int f = ceilingPowerOf2(n);
if (f <= n) {
    return f;
return f >> 1;
...
intfloorPowerOfTwo(final int a)
floor Power Of Two
if (a <= 0) {
    throw new IllegalArgumentException("a [" + a + "] must be > 0");
return Integer.highestOneBit(a);
longfloorSec(long milli)
floor Sec
return (milli / 1000L) * 1000L;
longfloorSec(long valueMs)
floor Sec
return convertToSec(valueMs) * SECOND;
intfloorSqrt(long i)
floor Sqrt
return (int) Math.sqrt(i);