math.ceil() vs math.floor()
math.ceil() and math.floor() are both Python Math Module APIs, and choosing between them is a common point of confusion. This page compares their syntax, parameters, return values, and typical use cases so you can pick the right one. math.ceil(): Returns the smallest integer greater than or equal to x. Its syntax is math.ceil(x), and it returns integer math.floor(): Returns the largest integer less than or equal to x. Its syntax is math.floor(x), and it returns integer Example of math.ceil(): math.ceil(3.14) # 4
math.ceil(-3.14) # -3. Example of math.floor(): math.floor(3.14) # 3
math.floor(-3.14) # -4. Read the full references for math.ceil() and math.floor() to see parameters, edge cases, and example code side by side. Other Math Module APIs worth comparing: math.trunc(), math.fabs(), math.sqrt(), math.pow(), math.exp(), math.log(). Both belong to the Math Module category in the Python Reference documentation. Try both in the Python playground to see the behavioral difference live.