It’s clear to me how these functions work on positive real numbers: you round up or down accordingly. But if you have to round a negative real number: to take −0.8 to −1, then do you take the floor of −0.8, or the ceiling?
That is, which of the following are true?
⌊−0.8⌋=−1
or
⌈−0.8⌉=−1
Answer
The first is the correct: you round “down” (i.e. the greatest integer LESS THAN −0.8).
In contrast, the ceiling function rounds “up” to the least integer GREATER THAN −0.8=0.
⌊−0.8⌋=−1since−1<−0.8<0⌈−0.8⌉=0since−1<−0.8<0
In general, we must have that ⌊x⌋≤x≤⌈x⌉∀x∈R
And so it follows that −1=⌊−0.8⌋≤−0.8≤⌈−0.8⌉=0
K.Stm’s suggestion is a nice, intuitive way to recall the relation between the floor and the ceiling of a real number x, especially when x<0. Using the “number line” idea and plotting −0.8 with the two closest integers that “sandwich” −0.8 gives us:
We see that the floor of x=−0.8 is the first integer immediately to the left of −0.8, and the ceiling of x=−0.8 is the first integer immediately to the right of −0.8, and this strategy can be used, whatever the value of a real number x.
Attribution
Source : Link , Question Author : Mirrana , Answer Author : amWhy