Ceiling function in math
The ceiling function returns the smallest integer that is greater than or equal to x. It is useful whenever a fractional result must be rounded upward to a whole count.
Examples include calculating the number of packages, groups, payment periods, or containers needed when a partial unit still requires a full unit.
Examples of ceiling function computation
For positive values, ceil(2.4) = 3 and ceil(7) = 7. For negative values, ceil(-2.4) = -2 because -2 is greater than -2.4 and is the nearest integer above it.
The key rule is not simply adding one. If x is already an integer, the ceiling result is the same integer.
- ceil(0.2) = 1
- ceil(3) = 3
- ceil(-1.8) = -1
Graph of the ceiling function
The graph of the ceiling function is a step graph. It stays flat between integers and jumps at each integer boundary.
Each interval maps to the next integer at or above every value in that interval.