Returns the largest (closest to positive infinity) double value that is less than or equal to the argument and is equal to a mathematical integer

The key is in the phrase that is less than or equal to the argument.

So 2.0 is the largest double value that is less than or equal to 2.1 that is also equal to an integer value.

Ditto for ceil: the description mentions the smallest value that is larger or equal to the input value...

So, the original descriptions are in fact correct.

Answer from Jason on Stack Overflow
🌐
W3Schools
w3schools.com › java › ref_math_ceil.asp
Java Math ceil() Method
System.out.println(Math.ceil(0.60)); ...intln(Math.ceil(-5.1)); System.out.println(Math.ceil(-5.9)); ... The ceil() method rounds a number UP to the nearest integer....
🌐
GeeksforGeeks
geeksforgeeks.org › mathematics › difference-between-floor-and-ceil-function
Difference Between Floor and Ceil Function - GeeksforGeeks
October 1, 2024 - Solution: floor of 67.212 is integer just lesser than 67.212 that is 67. So, floor of 67.212 is 67. Following is a table of Differences between Floor and Ceil Function:
Discussions

math - Java - Misunderstand ceil and floor methods - Stack Overflow
When I read "closest to positive infinity" and "closest to negative infinity" I think in the number line: ... EDIT: What I am asking is: the description broke my mind. My logic says (about floor for example): First, Ok when I listen floor I think in the smallest not in the largest. Second, if I returns the largest, that is greater not less than to the argument. The same happens with ceil... More on stackoverflow.com
🌐 stackoverflow.com
Why floor, round and ceil return double?
What if the number being passed into the function is higher than the biggest int? More on reddit.com
🌐 r/java
7
6
September 12, 2013
java - Math.ceil and Math.floor returning same value - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... And using the methods Math.ceil and Math.floor and parsing my double to these methods, I get the same value returned to me, which is 23... More on stackoverflow.com
🌐 stackoverflow.com
binary search ceiling and floor of number
I've stopped having difficulty with binary search since I adopted the following general strategy: The goal is to split all indices into 2 categories. For example the category arr[i] <= key and the category arr[i] > key. [start, end) is always the (half open) range of indices for which we don't know in which category they are. At the end we just need to decide if we need the largest element of the left category or the smallest element of the right category and return either arr[start-1] or arr[start] based on that. I'm not entirely sure what you mean by ceiling and floor. More on reddit.com
🌐 r/leetcode
7
5
October 9, 2022
🌐
How to do in Java
howtodoinjava.com › home › java math.ceil() vs. math.floor() vs. math.round()
Java Math.ceil() vs. Math.floor() vs. Math.round()
September 6, 2023 - Math.ceil() rounds up to the next highest integer, while Math.floor() rounds down to the next lowest integer. The Math.round() is used for rounding floating-point numbers to the nearest integer, following the “round half up” rule.
🌐
Guru99
guru99.com › home › java tutorials › java math – ceil() floor() methods
Java Math – ceil() Floor() Methods
September 20, 2024 - Below is the Math floor and ceiling Java example. public class Guru99 { public static void main(String args[]) { double d1 = 84.6; double d2 = 0.45; System.out.println("Ceiling of '" + d1 + "' = " + Math.ceil(d1)); System.out.println("Floor of '" + d1 + "' = " + Math.floor(d1)); System.out.println("Ceiling of '" + d2 + "' = " + Math.ceil(d2)); System.out.println("Floor of '" + d2 + "' = " + Math.floor(d2)); } } We will get the below output of the math.ceil in Java example.
🌐
LearnYard
read.learnyard.com › dsa › how-to-find-ceil-and-floor-solution-in-c-java-python-js
How to Find Ceil and Floor Solution In C++/Java/Python/JS
July 20, 2025 - How to find Ceil and Floor Problem Description Given a real number x, find: Ceil of x: The smallest integer that is greater than or equal to x. Floor of x: The largest integer that is less than or equal to x. You must return both values as output.
🌐
Programiz
programiz.com › java-programming › library › math › ceil
Java Math ceil()
Become a certified Java programmer. Try Programiz PRO! ... The ceil() method rounds the specified double value upward and returns it. The rounded value will be equal to the mathematical integer.
Find elsewhere
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Math.html
Math (Java Platform SE 8 )
October 20, 2025 - (In the foregoing descriptions, a floating-point value is considered to be an integer if and only if it is finite and a fixed point of the method ceil or, equivalently, a fixed point of the method floor.
🌐
Medium
medium.com › @AlexanderObregon › rounding-numbers-with-math-round-math-floor-and-math-ceil-in-java-d201bbeb85e2
Java’s Math Rounding Methods Explained | Medium
March 7, 2025 - Math.round() applies a half-up rule, shifting values based on a simple addition and truncation process. Math.floor() directly removes the decimal portion and moves toward negative infinity, while Math.ceil() does the opposite, always rounding up.
🌐
Programzools
programzools.com › find-ceil-and-floor-in-java.html
Find ceil and floor values in Java - ProgramZools
Floor value is the equivalent integer value by rounding down a float or double to the nearest integer (eg floor of 12.8 is 12). ceil(double a) of Math class can be used to rounding up a double value and floor method can be used to rounding down a double value.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-ceil-method-examples
Java ceil() method with Examples - GeeksforGeeks
April 4, 2023 - The Math.ceil() method in Java is used to return the smallest integer value that is greater than or equal to a given number. The returned value is of type double and represents the mathematical ceiling of the argument.
🌐
YouTube
youtube.com › java-fi study
🔴round() , ceil() , floor() || Mathematical Library Functions || ICSE || JAVA - YouTube
In this Java video in Hindi for I.C.S.E students and all beginners we explained Introduction of Mathematical Library Methods, Math.round() , Math.ceil() and ...
Published   August 25, 2021
Views   2K
🌐
Reddit
reddit.com › r/java › why floor, round and ceil return double?
r/java on Reddit: Why floor, round and ceil return double?
September 12, 2013 -

Might be stupid question, but this has always puzzled me about Java.

Why functions Math.floor(), Math.round() and Math.ceil() return double value?

I thought main point of those is to convert floating point number into whole number. So why not returning long or int? That way we don't have to manually cast everytime.

🌐
Oracle
docs.oracle.com › en › java › javase › 11 › docs › api › java.base › java › lang › Math.html
Math (Java SE 11 & JDK 11 )
January 20, 2026 - (In the foregoing descriptions, a floating-point value is considered to be an integer if and only if it is finite and a fixed point of the method ceil or, equivalently, a fixed point of the method floor.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Math › floor
Math.floor() - JavaScript | MDN
The Math.floor() static method ...Math.floor(5)); // Expected output: 5 console.log(Math.floor(-5.05)); // Expected output: -6 ... The largest integer smaller than or equal to x. It's the same value as -Math.ceil(-x)....
🌐
W3Schools
w3schools.com › jsref › jsref_ceil.asp
W3Schools.com
❮ Previous JavaScript Math Object ... Math.ceil(-5.1); let f = Math.ceil(-5.9); Try it Yourself » · The Math.ceil() method rounds a number rounded UP to the nearest integer....
🌐
Wikipedia
en.wikipedia.org › wiki › Floor_and_ceiling_functions
Floor and ceiling functions - Wikipedia
February 5, 2026 - Many programming languages (including C, C++, C#, Java, Julia, PHP, R, and Python) provide standard functions for floor and ceiling, usually called floor and ceil, or less commonly ceiling. The language APL uses ⌊x for floor. The J Programming Language, a follow-on to APL that is designed to use standard keyboard symbols, uses <. for floor and >. for ceiling.
🌐
Quora
quora.com › What-is-the-use-of-the-Ceil-Floor-and-Rint-functions-in-Java
What is the use of the Ceil(), Floor, and Rint functions in Java? - Quora
* ceil(x) returns the smallest integer bigger than x. * floor(x) returns the largest integer smaller than x. * rint(x) returns the integer closest to x. If x is a number ending in ...