Textbook
The floor of a real number $x$, written $\lfloor x\rfloor$, is the greatest integer no larger than $x$. If $k=\lfloor x\rfloor$, then $k\le x<k+1$. For integer $x$, the identity is $\lfloor x\rfloor=x$.
For example, $\lfloor2.7\rfloor=2$, but $\lfloor-2.7\rfloor=-3$. Discarding fractional digits moves toward zero and therefore gives another result for negative nonintegers. Floor always moves toward smaller numbers. For positive integers $n,c$, the value $\lfloor n/c\rfloor$ counts complete groups of size $c$ contained in $n$.
The definition determines one result because two different integers cannot both satisfy $k\le x<k+1$. The remainder $x-\lfloor x\rfloor$ lies in $[0,1)$ even for a negative input. Rounding down can therefore change a number by almost one, but never by a full unit. For an integer input the change is zero; βdownβ does not require making an already integral value smaller.
Definitions and further reading: Mathematics for Computer Science.
In plain language
The floor is the nearest integer step at or below a number, so β2.7 has floor β3. Removing the fractional part agrees with that rule to the right of zero but goes the wrong way on the left. The chosen integer must not exceed the input, and the next integer must be greater than it. Number order determines the direction; deleting a written tail is not a universal shortcut to rounding.
Example
The illustrative input β2.7 allows a comparison of two integer candidates and a check of the defining inequality. This negative case separates floor from truncation toward zero.
The Floor Function: Rounding Down
Candidate β2
The number β2 exceeds β2.7 and does not qualify.
Step 1 of 3: Candidate β2
Read all steps
Candidate β2
The number β2 exceeds β2.7 and does not qualify.
- State
- β3β2.7β2excluded
Candidate β3
The number β3 does not exceed the input.
- State
- β3includedβ2.7β2excluded
The next integer
The next integer β2 is already above the input, so the candidate is greatest.
- State
- β3currentβ2.7currentβ2current
For β2.7, the gap above its chosen floor β3 is 0.3, while the next integer β2 lies above the input. Candidate β4 is also below β2.7 but is not the greatest admissible integer because β3 comes between them. Checking βno greater than the inputβ alone is insufficient. The second inequality excludes unnecessarily low answers and confirms the nearest integer step below.