y=xy = \lfloor x \rfloor

Graph of the Floor Function y=xy = \lfloor x \rfloor

y=xy = \lfloor x \rfloor returns the largest integer not exceeding xx1. It is called the floor function, and it is easiest to picture as the first integer you meet looking to the left from xx along the number line.

xxx\lfloor x \rfloor
2.72.722
3333
0.5-0.51-1
1.2-1.22-2

Domain and range

The domain is all real numbers. The value returned is always an integer, so the range is the set of all integers, a discrete collection rather than a continuous line. Only integer heights are ever taken.

Shape of the graph

The graph is a staircase. Each step is a horizontal segment of length 11, and the value jumps up by 11 at every integer.

IntervalValue
[1,0)[-1, 0)1-1
[0,1)[0, 1)00
[1,2)[1, 2)11

Each step includes its left end and excludes its right end. On 1x<21 \leq x < 2 the value is always 11, and the moment xx reaches 22 it jumps to 22.

Points of discontinuity

The function is discontinuous at every integer. Approaching an integer nn from the right the limit is nn, while from the left it is n1n - 1, and the two disagree. The size of the jump is always 11.

At non-integer points the value is constant nearby, so the function is differentiable there with derivative 00. It is made of nothing but flat steps of slope 00 and sudden jumps.

Monotonicity

The value never decreases as xx increases, so the function is non-decreasing. It is not strictly increasing, however, since the value stays put along each step.

A caution with negative numbers

Note that 1.2=2\lfloor -1.2 \rfloor = -2, not 1-1. The floor function does not discard the fractional part; it always rounds toward -\infty. That differs from the integer division of many programming languages, which rounds toward 00, so negative numbers deserve care.

Relations to other functions

  • The ceiling function x\lceil x \rceil, returning the smallest integer at least xx, is its counterpart
  • The difference xxx - \lfloor x \rfloor is the fractional part, a sawtooth wave of period 11
  • Rounding to the nearest integer can be written x+0.5\lfloor x + 0.5 \rfloor

Applications

The number of digits of a positive integer NN is found with the floor function.

log10N+1\lfloor \log_{10} N \rfloor + 1

The quotient of an integer division ab\left\lfloor \dfrac{a}{b} \right\rfloor, the computation of array indices and the paging of a list all use it: wherever a continuous quantity has to be cut into steps.

  1. Floor and ceiling functions, Wikipedia