Range of Values of Floor Function
Contents |
Theorem
Let $x \in \R$ be a real number and let $\left \lfloor{x}\right \rfloor$ be the floor of $x$.
Let $n \in \Z$ be an integer.
Then the following results apply:
- $(1): \qquad \left \lfloor{x}\right \rfloor < n \iff x < n$
- $(2): \qquad \left \lfloor{x}\right \rfloor \ge n \iff x \ge n$
- $(3): \qquad \left \lfloor{x}\right \rfloor = n \iff x - 1 < n \le x$
- $(4): \qquad \left \lfloor{x}\right \rfloor = n \iff n \le x < n + 1$
Proof
We are going to use throughout the fact that $\forall m, n \in \Z: m < n \iff m \le n - 1$.
Proof of Result 1
Let $\left \lfloor{x}\right \rfloor < n$.
Then:
| \(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \left \lfloor{x}\right \rfloor\) | \(<\) | \(\displaystyle n\) | \(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \) | |||
| \(\displaystyle \) | \(\displaystyle \implies\) | \(\displaystyle \) | \(\displaystyle \left \lfloor{x}\right \rfloor + 1\) | \(\le\) | \(\displaystyle n\) | \(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \) | |||
| \(\displaystyle \) | \(\displaystyle \implies\) | \(\displaystyle \) | \(\displaystyle x\) | \(<\) | \(\displaystyle \left \lfloor{x}\right \rfloor + 1\) | \(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \) | |||
| \(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \) | \(\le\) | \(\displaystyle n\) | \(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \) | |||
| \(\displaystyle \) | \(\displaystyle \implies\) | \(\displaystyle \) | \(\displaystyle x\) | \(<\) | \(\displaystyle n\) | \(\displaystyle \) | \(\displaystyle \) | \(\displaystyle \) |
Next suppose $x < n$.
Then as $\left \lfloor {x} \right \rfloor \le x$ it follows that $\left \lfloor {x} \right \rfloor < n$.
So $\left \lfloor{x}\right \rfloor < n \iff x < n$.
$\blacksquare$
Proof of Result 2
Let $\left \lfloor{x}\right \rfloor \ge n$.
Then as $x \ge \left \lfloor{x}\right \rfloor$ it follows that $x \ge n$.
Now let $x \ge n$.
Suppose $\left \lfloor{x}\right \rfloor < n$.
Then $\left \lfloor{x}\right \rfloor + 1 \le n$ and so $\left \lfloor{x}\right \rfloor + 1 \le x$, which is a contradiction of $\left \lfloor{x}\right \rfloor + 1 > x$.
Thus by proof by contradiction, $\left \lfloor{x}\right \rfloor \ge n$.
So $\left \lfloor{x}\right \rfloor \ge n \iff x \ge n$.
$\blacksquare$
Proof of Result 3
Suppose $\left \lfloor{x}\right \rfloor = n$.
Then $\left \lfloor{x}\right \rfloor \ge n$ and so by result 2, $n \le x$.
Also, we have that $x - 1 < \left \lfloor{x}\right \rfloor = n$ and so $x - 1 < n$.
So $\left \lfloor{x}\right \rfloor = n \implies x - 1 < n \le x$.
Now suppose $x - 1 < n \le x$.
From $n \le x$, we have by result 2 that $n \le \left \lfloor{x}\right \rfloor$.
From $x - 1 < n$ we have that $x < n + 1$.
Hence by result 1 we have $\left \lfloor{x}\right \rfloor < n + 1$ and so $\left \lfloor{x}\right \rfloor \le n$.
Thus as $n \le \left \lfloor{x}\right \rfloor$ and $\left \lfloor{x}\right \rfloor \le n$ it follows that $\left \lfloor{x}\right \rfloor = n$.
Thus $x - 1 < n \le x \implies \left \lfloor{x}\right \rfloor = n$.
So $\left \lfloor{x}\right \rfloor = n \iff x - 1 < n \le x$.
$\blacksquare$
Proof of Result 4
Suppose $\left \lfloor{x}\right \rfloor = n$.
We have already shown that $n \le x$ (from result 2).
We also have that $\left \lfloor{x}\right \rfloor + 1 = n + 1$.
But from above, we have $x < \left \lfloor {x} \right \rfloor + 1$, and so $x < n + 1$.
So $\left \lfloor{x}\right \rfloor = n \implies n \le x < n + 1$.
Now suppose $n \le x < n + 1$.
We have already shown that $n \le x \implies n \le \left \lfloor{x}\right \rfloor$ by result 2.
In result 3 we saw that $x < n + 1 \implies \left \lfloor{x}\right \rfloor \le n$.
Thus $n \le x < n + 1 \le x \implies \left \lfloor{x}\right \rfloor = n$.
So $\left \lfloor{x}\right \rfloor = n \iff n \le x < n + 1 \le x$.
$\blacksquare$
Also see
Sources
- Donald E. Knuth: The Art of Computer Programming: Volume 1: Fundamental Algorithms (1968): $\S 1.2.4$: Exercise $3$