The ceil function (short for "ceiling") returns the smallest integer that is greater than or equal to a given number. It effectively rounds a number up to the nearest integer.
Key Details:
Mathematical Definition: For any real number $ x $, $ \lceil x \rceil $ is the least integer not less than $ x $.
Example: $ \lceil 2.3 \rceil = 3 $, $ \lceil -2.3 \rceil = -2 $.
In Programming Languages:
C/C++:
ceil()is in<cmath>or<math.h>. Returnsdouble.#include <cmath> std::cout << std::ceil(2.3); // Output: 3Java:
Math.ceil()returnsdouble.Math.ceil(2.3); // Returns 3.0JavaScript:
Math.ceil()returns the smallest integer ≥ input.Math.ceil(2.3); // Returns 3Python: Use
math.ceil()(frommathmodule).import math math.ceil(2.3) # Returns 3SQL (Oracle, Redshift, etc.):
CEIL(n)orCEILING(n)returns smallest integer ≥ $ n $.SELECT CEIL(2.3) FROM DUAL; -- Returns 3Excel:
CEILING(number, significance)rounds up to the nearest multiple of significance (not just to the next integer).=CEILING(4.42, 0.05) // Returns 4.45 (nearest nickel)
Special Cases:
If the input is already an integer,
ceilreturns the same value.For negative numbers, it rounds toward zero (e.g.,
ceil(-2.3)is-2).If the input is
NaN,±∞, or±0, the function returns the same value.
Note: In most languages,
ceil()returns a floating-point number (e.g.,doubleorfloat) even when the result is an integer.



