How is math.ceil(89.7) different from math.floor(89.7)?
math.ceil(89.7) returns the ceiling value of 89.7, which is 90. The ceil() function returns the smallest integer greater than or equal to the given number. It rounds up the value to the next integer.
math.floor(89.7) returns the floor value of 89.7, which is 89. The floor() function returns the greatest integer less than or equal to the given number. It rounds down the value to the previous integer.
Thus, the key difference is that math.ceil(89.7) gives 90 while math.floor(89.7) gives 89. The ceil() function rounds up whereas floor() function rounds down the floating point number.
Explanation
The textbook Table 7.2 clearly explains both functions. For math.ceil(), the example shows math.ceil(9.7) returns 10, demonstrating that ceil rounds up. For math.floor(), the example shows math.floor(4.5) returns 4, demonstrating that floor rounds down. Applying this logic to 89.7: ceil(89.7) = 90 and floor(89.7) = 89.
Solution Steps
Step 1: math.ceil(89.7) rounds up to the next integer → returns 90
Step 2: math.floor(89.7) rounds down to the previous integer → returns 89
Step 3: The difference is 90 - 89 = 1, showing ceil rounds up while floor rounds down