How do the floor and ceiling functions work on negative numbers?

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$.

$$ \begin{align} \lfloor{-0.8}\rfloor & = -1\quad & \text{since}\;\; \color{blue}{\bf -1} \lt -0.8 \lt 0 \\ \\ \lceil {-0.8} \rceil & = 0\quad &\text{since} \;\; -1 \lt -0.8 \lt \color{blue}{\bf 0} \end{align}$$

In general, we must have that $$\lfloor x \rfloor \leq x\leq \lceil x \rceil\quad \forall x \in \mathbb R$$

And so it follows that $$-1 = \lfloor -0.8 \rfloor \leq -0.8 \leq \lceil -0.8 \rceil = 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\lt 0$. Using the "number line" idea and plotting $-0.8$ with the two closest integers that "sandwich" $-0.8$ gives us:

$\qquad\qquad$enter image description here

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$.


Keep in mind that $\lfloor x \rfloor \le x \le \lceil x \rceil$, so it's the first one.

More precisely, for $x \in \Bbb{R}$, $$ \lfloor x \rfloor = \max \{ z \in \Bbb{Z} : z \le x \} $$ while $$ \lceil x \rceil = \min \{ z \in \Bbb{Z} : x \le z \}. $$


The first one is true: $\lfloor x\rfloor\le x\le\lceil x\rceil$, no matter if $x$ is negative or not.