Algebra • Step Functions & Integer Parts

Floor Function Calculator

Evaluate the floor function ⌊x⌋ (greatest integer less than or equal to x) step-by-step. Discover bounding intervals, fractional parts, negative decimal rules, and interactive staircase step plots.

|
Last Updated: September 2026
|
Verified Accurate: Mathematical & Computational Rigor
Algebra • Step Functions & Integer Parts Evaluated
Curriculum Presets: Click to load & evaluate
Supports decimals, fractions (e.g. 7/3, -11/4), or π
x ∈ ℝ
Floor Function Output: ⌊x⌋ 3 ≤ 3.99 < 4
3
Greatest integer ≤ 3.99
Fractional Part {x}
0.99
x - ⌊x⌋ ∈ [0, 1)
Ceiling ⌈x⌉
4
Least integer ≥ x
Nearest Integer [x]
4
Standard round(x)
Integer Parity
Odd Integer
Floor parity state
Interactive Step Function Visualization: y = ⌊x⌋ Staircase steps & dynamic coordinate marker
Staircase Steps [k, k+1) Included Left Endpoint [k, k] Excluded Right (k+1, k) Current Evaluation (x, ⌊x⌋)

Step-by-Step Mathematical Derivation

Consecutive Integer Inequality
Direct Answer & Overview
Verified Educational Guide

Floor Function Overview & Direct Answer

The floor function, written as ⌊x⌋ or [x], returns the greatest integer that is less than or equal to x. For positive numbers and zero, ⌊x⌋ equals the integer part obtained by dropping the decimal digits (e.g., ⌊3.99⌋ = 3). For negative non-integers, rounding moves leftward toward negative infinity, making ⌊-3.14⌋ = -4. Every real number x uniquely satisfies k ≤ x < k + 1 where k = ⌊x⌋ ∈ ℤ.

Primary Mathematical Formula Formal Greatest Integer Definition via Upper-Bounded Integer Sets
Standard Equation
ƒ(x)
Q.E.D.
⌊x⌋=max⁡{k∈Z∣k≤x}\lfloor x \rfloor = \max \{ k \in \mathbb{Z} \mid k \le x \}
Satisfies the fundamental double inequality ⌊x⌋ ≤ x < ⌊x⌋ + 1, with equality if and only if x is an integer.
Exact Formula
Input Parameters
Required
1
Input Real Number (x): Any real numerical scalar, signed decimal, rational fraction (e.g. 22/7, -11/4), or standard mathematical constant (pi, e).
Expected Outputs
Calculated
Floor Value ⌊x⌋: The unique greatest integer less than or equal to x (lower integer bracket).
Fractional Part {x}: The non-negative fractional residue x - ⌊x⌋ spanning the interval [0, 1).
Ceiling Value ⌈x⌉: The dual least integer greater than or equal to x.
Consecutive Integer Bracket: The exact bounding inequality k ≤ x < k + 1.
Worked Numerical Example
Instant Verification
Evaluate ⌊-3.14⌋
→ Step 1: Locate -3.14 on the real number line. Step 2: Identify consecutive integers bounding -3.14: -4 ≤ -3.14 < -3. Step 3: By definition, the greatest integer less than or equal to -3.14 is the leftward integer -4.
-4

Formal Mathematical Definition & Notation

The floor function is a fundamental non-linear operator spanning real analysis, discrete mathematics, and computer science. Historically introduced by Carl Friedrich Gauss in his third proof of quadratic reciprocity (1808) and later standardized with Kenneth Iverson's ceiling and floor notation in A Programming Language (1962), the function formalizes the intuitive notion of rounding down to the nearest integer.

Let $\mathbb R$ denote the set of real numbers and $\mathbb Z$ denote the set of integers. For any $x \in \mathbb R$, the set of integers bounded above by $x$, denoted $S_x = \lbrace k \in \mathbb Z \mid k \le x \rbrace$, is non-empty by the Archimedean property of the real numbers and bounded above by $x$. By the well-ordering principle of the integers, $S_x$ contains a unique maximal element:

⌊x⌋ = max { k ∈ ℤ : k ≤ x }

In traditional mathematical literature, the floor function was frequently denoted with square brackets $[x]$ and referred to as the greatest integer function. However, modern mathematical convention universally prefers the half-bracket notation $\lfloor x \rfloor$ to eliminate ambiguity with standard grouping brackets and equivalence classes. For parallel integer division operations, our companion Floor Division Calculator explores algorithmic integer quotient arithmetic.

The Consecutive Integer Bounding Inequality

The operational definition of the floor function is expressed as a double inequality that uniquely characterizes $\lfloor x \rfloor$. For any real number $x$, there exists one and only one integer $k$ such that:

k ≤ x < k + 1  ⇔  ⌊x⌋ = k

This inequality splits into two critical assertions:

  • Lower Bound: $\lfloor x \rfloor \le x$, ensuring that the floor function never exceeds the original number.
  • Upper Strict Bound: $x < \lfloor x \rfloor + 1$, guaranteeing that the floor value is the largest such integer. Rearranging this gives $x - 1 < \lfloor x \rfloor \le x$.

Subtracting $\lfloor x \rfloor$ from all terms in the bounding inequality yields the fundamental constraint on the fractional residue: $0 \le x - \lfloor x \rfloor < 1$.

Negative Decimals & The Leftward Direction Rule

The most prevalent student error when working with the floor function occurs with negative non-integers. Many students incorrectly assume that evaluating $\lfloor -3.7 \rfloor$ simply strips the decimal to yield $-3$. This is mathematically false because $-3$ is strictly greater than $-3.7$, violating the condition $k \le x$.

The Number Line Leftward Direction Principle:

Consider the numbers $-5, -4, -3, -2, -1, 0, 1$ arranged along the standard Cartesian axis. To find $\lfloor x \rfloor$, locate $x$ on the line and look directly to the left (toward $-\infty$) for the nearest integer mark:

… —— [-4] ←←←← [-3.7] ———— [-3] ———— [-2] —— …

Because $-3.7$ lies strictly between $-4$ and $-3$ (that is, $-4 \le -3.7 < -3$), the greatest integer less than or equal to $-3.7$ is $-4$.

In contrast, for exact integers, whether positive or negative, the floor function leaves the value unchanged: $\lfloor -5 \rfloor = -5$, $\lfloor 0 \rfloor = 0$, and $\lfloor 8 \rfloor = 8$.

Fractional Part Decomposition & Residue Analysis

Every real number $x \in \mathbb R$ admits a unique canonical additive decomposition into its discrete integer floor and its continuous fractional residue:

x = ⌊x⌋ + {x},   where {x} ∈ [0, 1)

The fractional part function {x} = x - ⌊x⌋ exhibits key properties that differentiate it from naive digit-dropping:

  • Strict Positivity / Semi-Open Range: {x} is always bounded in $[0, 1)$. It can equal zero (if and only if $x \in \mathbb Z$), but it can never reach $1$.
  • Periodicity: The fractional part is periodic with period $1$: {x + 1} = (x + 1) - ⌊x + 1⌋ = x + 1 - (⌊x⌋ + 1) = {x}. This forms the basis of the sawtooth wave in Fourier analysis.
  • Negative Number Fractional Part: For $x = -2.25$, ⌊-2.25⌋ = -3, yielding {-2.25} = -2.25 - (-3) = +0.75. Notice that the fractional part remains strictly positive!

Step Function Geometry & Discontinuity Jump Analysis

Graphically, the function $f(x) = \lfloor x \rfloor$ forms an infinite staircase of horizontal line segments. Each step resides at height $y = k$ over the half-open interval $[k, k + 1)$:

  • Left Endpoint Inclusion: At $x = k$, the step includes the point $(k, k)$, depicted graphically as a solid circle.
  • Right Endpoint Exclusion: As $x \to (k+1)^-$, the function maintains the value $k$. At $x = k + 1$, the value jumps instantaneously to $k + 1$. Thus, the point $(k + 1, k)$ is excluded, depicted graphically as an open circle.
  • Jump Discontinuity: At every integer $k \in \mathbb{Z}$, the left-hand limit and right-hand limit disagree: $$\lim_{x \to k^-} \lfloor x \rfloor = k - 1, \qquad \lim_{x \to k^+} \lfloor x \rfloor = k$$ Because the jump size is $\lim_{x \to k^+} \lfloor x \rfloor - \lim_{x \to k^-} \lfloor x \rfloor = k - (k - 1) = 1$, the floor function has a countable infinity of simple jump discontinuities.
  • Right-Continuity: Because $f(k) = \lim_{x \to k^+} f(x) = k$, the floor function is everywhere right-continuous ($\mathcal{C}^0$ from the right).

Essential Algebraic Properties & Hermite's Identity

The floor operator satisfies a rich suite of algebraic identities that permit manipulation inside summations, integrals, and equations:

Integer Shift Invariance

Adding an integer $m \in \mathbb{Z}$ inside the floor passes directly outside:

⌊x + m⌋ = ⌊x⌋ + m,   ∀ m ∈ ℤ
Reflection Identity

Reflecting $x$ across zero links the floor and ceiling operators:

⌊-x⌋ = -⌈x⌉ = -⌊x⌋ - [x ∉ ℤ]

One of the deepest results in analytic number theory is Hermite's Floor Identity. For any real $x$ and any positive integer $n \in \mathbb{Z}^+$:

⌊nx⌋ = ∑k=0n-1 ⌊x + k/n⌋ = ⌊x⌋ + ⌊x + 1/n⌋ + … + ⌊x + (n-1)/n⌋

For $n = 2$, this simplifies to the elegant doubling relation: $\lfloor 2x \rfloor = \lfloor x \rfloor + \lfloor x + 1/2 \rfloor$.

Floor vs. Ceiling vs. Integer Truncation Comparison

Engineers and programmers frequently conflate three distinct integer conversion operations. The comparative table below clarifies their divergent behaviors across positive, negative, and fractional inputs:

Input (x) Floor ⌊x⌋ (Towards -∞) Ceiling ⌈x⌉ (Towards +∞) Truncation trunc(x) (Towards 0) Round round(x) (Nearest)
4.75 4 5 4 5
4.25 4 5 4 4
3.00 3 3 3 3
-0.25 -1 0 0 0
-3.75 -4 -3 -3 -4

Computer Science, Discrete Math & Signal Applications

Far from being an abstract curiosity, the floor function drives critical algorithms in computational systems:

  • Hash Table Indexing & Bucket Sort: When distributing uniform continuous keys $x \in [0, 1)$ into $B$ discrete array buckets, the target bucket index is computed via $i = \lfloor B \cdot x \rfloor$.
  • Digital Signal Processing (DSP) & PCM Quantization: Analog-to-digital converters (ADCs) quantize continuous voltage inputs into $N$-bit digital integer levels using floor-based step functions: $q = \lfloor (v - v_{\min}) / \Delta \rfloor$.
  • Calendar Algorithms & Leap Year Calculations: Computing Julian day numbers and Gregorian leap years relies heavily on the floor operator: the number of leap years between year $1$ and year $Y$ is given by $\lfloor Y/4 \rfloor - \lfloor Y/100 \rfloor + \lfloor Y/400 \rfloor$.
  • Prime Counting & Legendre's Formula: The exact exponent of prime $p$ dividing $n!$ (Legendre's formula) is evaluated via de Polignac's infinite floor series: $$E_p(n!) = \sum_{k=1}^{\infty} \left\lfloor \frac{n}{p^k} \right\rfloor$$

Common Pitfalls & Edge Cases

  • Floating-Point Binary Inexactness: In IEEE-754 double precision arithmetic, values like $0.1 + 0.2$ evaluate to $0.30000000000000004$. Evaluating $\lfloor 10 \cdot (0.1 + 0.2) \rfloor$ can inadvertently yield $3$ instead of expected boundary behaviors. Numerical algorithms use epsilon buffers ($\epsilon = 10^{-12}$) near integer boundaries.
  • Distributivity Over Multiplication Fails: While addition of an integer distributes ($\lfloor x + m \rfloor = \lfloor x \rfloor + m$), multiplication does not: $\lfloor 2 \cdot 1.7 \rfloor = \lfloor 3.4 \rfloor = 3$, whereas $2 \cdot \lfloor 1.7 \rfloor = 2 \cdot 1 = 2$.
  • Sign Flip Inversion: It is tempting to write $\lfloor -x \rfloor = -\lfloor x \rfloor$. This equality holds only when $x$ is an exact integer. For non-integers, $\lfloor -x \rfloor = -\lfloor x \rfloor - 1$.
Fact-Checked & Verified • Computational Accuracy Standards
Updated September 2026 • Editorial Policy
Authored By
Sanjay Samanta

Lead Developer & Founder of Basic Math Tools. Specializes in browser-native computational algorithms and applied mathematics.

Reviewed & Verified By
Academic Review Board

Mathematics & curriculum specialists. Audited against standard algebraic and arithmetic principles.

Found an error or have an improvement suggestion? Report a calculation issue

Frequently Asked Questions

What is the floor function in mathematics?
The floor function, denoted ⌊x⌋ or [x], is a step function that maps any real number x to the greatest integer that is less than or equal to x. Formally, ⌊x⌋ = max{k ∈ ℤ | k ≤ x}. For example, ⌊4.8⌋ = 4, ⌊7.0⌋ = 7, and ⌊-2.3⌋ = -3.
Why is the floor of a negative decimal like -3.2 equal to -4 instead of -3?
Because the floor function rounds down towards negative infinity (leftward on the standard real number line). On the number line, -4 lies to the left of -3.2, whereas -3 lies to the right. Since -3 is strictly greater than -3.2, it fails the condition 'less than or equal to x'. Thus, the greatest integer less than or equal to -3.2 is -4.
What is the difference between the floor function and integer truncation (int)?
Integer truncation (often written as int(x) or trunc(x)) simply discards the decimal portion by rounding toward zero. For positive numbers, floor and truncation are identical (⌊3.9⌋ = 3 and int(3.9) = 3). However, for negative numbers, they diverge: trunc(-3.9) = -3 (moving toward zero), while ⌊-3.9⌋ = -4 (moving toward negative infinity).
How is the fractional part of a real number defined using the floor function?
The fractional part of x, denoted {x}, is defined as {x} = x - ⌊x⌋. By definition, the fractional part is always non-negative and strictly less than 1 (0 ≤ {x} < 1) for every real number x. For instance, {3.7} = 3.7 - 3 = 0.7, and {-3.7} = -3.7 - (-4) = 0.3.
What is the relationship between the floor function and the ceiling function?
The floor function ⌊x⌋ returns the greatest integer ≤ x, whereas the ceiling function ⌈x⌉ returns the least integer ≥ x. If x is an integer, ⌊x⌋ = ⌈x⌉ = x. If x is not an integer, ⌈x⌉ = ⌊x⌋ + 1. Furthermore, they satisfy the reflection identity ⌊-x⌋ = -⌈x⌉.
Is the floor function continuous, differentiable, or integrable?
The floor function is piecewise constant, meaning it is continuous on every open interval (k, k + 1) for k ∈ ℤ. It possesses jump discontinuities of magnitude 1 at every integer k. Because of these jumps, it is not differentiable at integers (derivative is 0 everywhere on non-integer intervals), but it is Riemann integrable on any compact interval.
How does the floor function relate to floor division in computer science?
Floor division a // b evaluates the quotient a/b and immediately applies the floor function: a // b = ⌊a / b⌋. In programming languages such as Python, -7 // 3 evaluates to ⌊-2.333...⌋ = -3, matching the mathematical floor definition.