MCPcopy Create free account
hub / github.com/TheAlgorithms/Java / floor

Method floor

src/main/java/com/thealgorithms/maths/Floor.java:15–23  ·  view source on GitHub ↗

Returns the largest (closest to positive infinity) @param number the number @return the largest (closest to positive infinity) of given number

(double number)

Source from the content-addressed store, hash-verified

13 * {@code number}
14 */
15 public static double floor(double number) {
16 if (number - (int) number == 0) {
17 return number;
18 } else if (number - (int) number > 0) {
19 return (int) number;
20 } else {
21 return (int) number - 1;
22 }
23 }
24}

Callers 15

testFloorWholeNumberMethod · 0.95
testFloorDoubleNumberMethod · 0.95
testFloorNegativeZeroMethod · 0.95
colorCodedColorMapMethod · 0.45
wiggleSortMethod · 0.45
processEndpointMethod · 0.45
drawMainLineMethod · 0.45
fpartMethod · 0.45
roundMethod · 0.45
jugglerSequenceMethod · 0.45
numberOfDigitsFastMethod · 0.45
fermatPrimeCheckingMethod · 0.45

Calls

no outgoing calls

Tested by 3

testFloorWholeNumberMethod · 0.76
testFloorDoubleNumberMethod · 0.76
testFloorNegativeZeroMethod · 0.76