Skip to content

The Floor Function: Rounding Down

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
  1. Candidate βˆ’2

    The number βˆ’2 exceeds βˆ’2.7 and does not qualify.

    State
    βˆ’3βˆ’2.7βˆ’2excluded
  2. Candidate βˆ’3

    The number βˆ’3 does not exceed the input.

    State
    βˆ’3includedβˆ’2.7βˆ’2excluded
  3. 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.

Related concepts: Integers, Ceiling.

The original text of this free article is published under CC BY-NC-ND 4.0.

Previous / next

Previous
Logarithms: Finding the Exponent
Next
The Ceiling Function: Rounding Up
  • Natural Numbers: Counting Discrete Objects

    Which values count discrete objects, and why the zero convention must be stated.

    Read article
    Math
  • Integers: Counting on Both Sides of Zero

    Positive and negative integers, zero, and the limits of integer division.

    Read article
    Math
  • Rational Numbers: Ratios of Integers

    Numbers as ratios of integers: equivalent fractions and the nonzero denominator requirement.

    Read article
    Math