What Is the Floor Function?
The floor function takes any real number and returns the greatest integer that does not exceed it. Mathematically, for a number x, the floor returns the largest integer n from the set of all integers where n ≤ x.
Common notation uses square brackets: ⌊x⌋. For example:
- ⌊3⌋ = 3 (it's already an integer)
- ⌊3.7⌋ = 3 (the greatest integer ≤ 3.7)
- ⌊−2.3⌋ = −3 (the greatest integer ≤ −2.3, not −2)
- ⌊π⌋ = 3 (since π ≈ 3.14159...)
The function maps all real numbers onto the set of integers, forming a step-like pattern when graphed. Each horizontal segment spans an interval of length 1 on the real number line.
Floor Function Formula
The floor function is defined as the maximum integer not exceeding the input:
⌊x⌋ = max{n ∈ ℤ : n ≤ x}
x— Any real number (integer, decimal, or negative)⌊x⌋— The floor of x; always an integer
Key Properties of the Floor Function
Understanding these mathematical properties helps predict floor function behavior without calculation:
- Bounding property: Any real number sits strictly between its floor and floor plus one: ⌊x⌋ ≤ x < ⌊x⌋ + 1
- Integer gaps: The distance from a number to its floor never exceeds 1: x − 1 < ⌊x⌋ ≤ x
- Integer addition: Adding an integer n to the input gives ⌊x + n⌋ = ⌊x⌋ + n
- Idempotence: Applying the floor twice yields the same result as applying it once: ⌊⌊x⌋⌋ = ⌊x⌋
- Not one-to-one: Multiple inputs map to the same output (e.g., both 2.1 and 2.9 have floor 2)
Graph and Continuity
The floor function produces a distinctive step graph with horizontal segments and vertical jumps at every integer. Filled dots mark included endpoints (at integers), and empty dots mark excluded endpoints.
The function is discontinuous at all integer values. At each integer n, the function jumps from n − 1 to n. For non-integer values, the function is continuous—it remains flat across each interval [n, n+1).
Despite its step-like appearance, the floor function remains well-defined everywhere and is fully invertible if you track which interval the input falls within.
Common Pitfalls and Practical Tips
Avoid these frequent mistakes when working with floor functions:
- Negative numbers behave differently — ⌊−2.3⌋ equals −3, not −2. The floor always rounds toward negative infinity, not toward zero. Many programming languages have separate functions: floor (toward −∞) and trunc (toward 0).
- Discontinuity means no derivative at integers — The floor function has no derivative at integer points because it jumps instantaneously. Between integers, you could argue it has a derivative of zero, but this is rarely useful.
- Rounding down is not the same as floor — For positive numbers, floor equals rounding down. For negative numbers, they differ. Floor of −1.5 is −2; rounding down −1.5 might give −1 depending on convention.
- Check your programming language's syntax — Python uses math.floor(), Excel uses FLOOR.MATH(), SQL varies by database. Always verify your tool's exact behavior with test cases before relying on it in production code.