Last verified · v1.0
Calculator · math
Floor Function Calculator
Compute ⌊x⌋ instantly with this floor function calculator. Supports floor, ceiling, truncate, and round operations for any real number.
Inputs
Result
—
Explain my result
Get a plain-English breakdown of your result with practical next steps.
The formula
How the
result is
computed.
Understanding the Floor Function
The floor function, written as ⌊x⌋, maps any real number to the greatest integer less than or equal to that number. The formal definition is: ⌊x⌋ = max{n ∈ ℤ | n ≤ x}, meaning the largest integer n that does not exceed x. According to GWU School of Engineering & Applied Science — Module 6: Real Numbers, integer functions such as floor form a cornerstone of computer science and discrete mathematics, underpinning everything from array indexing to cryptographic algorithms.
Key Variables
- Input Value (x): Any real number — positive, negative, or zero — to which the selected rounding operation is applied.
- Operation: The integer-rounding method chosen: floor ⌊x⌋, ceiling ⌈x⌉, truncate (round toward zero), or standard round (half-up convention). Each produces a distinct integer result for non-integer inputs.
How the Floor Function Works
The floor function always rounds toward negative infinity, never toward zero. This distinction is critical for negative inputs:
- ⌊3.9⌋ = 3 — the fractional part 0.9 is discarded, leaving 3
- ⌊7.0⌋ = 7 — integers map to themselves
- ⌊−2.1⌋ = −3 — rounds down to −3, not up to −2
- ⌊−5.0⌋ = −5 — negative integers are also unchanged
The MDN Web Docs reference for Math.floor() confirms this behavior explicitly: the method returns the largest integer less than or equal to the argument, which for negative decimals means a result more negative than the input.
The Fundamental Identity
For every real number x, the floor function satisfies the inequality: ⌊x⌋ ≤ x < ⌊x⌋ + 1. This identity uniquely determines the floor value and serves as the operational definition in computational implementations. The SDSU SageMath Calculator Tutorial demonstrates this property in practice through symbolic computation, confirming that floor(x) always yields the integer immediately to the left of x on the number line.
Related Integer Functions
Ceiling Function ⌈x⌉
The ceiling function is the complement of floor — it returns the smallest integer greater than or equal to x. For example, ⌈3.2⌉ = 4 and ⌈−2.7⌉ = −2. For exact integers, floor and ceiling agree: ⌊5⌋ = ⌈5⌉ = 5.
Truncation (Round Toward Zero)
Truncation removes the fractional part, rounding toward zero regardless of sign. For positive numbers, truncation equals floor: trunc(4.9) = ⌊4.9⌋ = 4. For negative numbers, they diverge: trunc(−2.9) = −2, while ⌊−2.9⌋ = −3. This is the behavior of integer casting in most programming languages.
Standard Rounding (Half-Up)
Standard rounding applies the half-up rule: fractional parts below 0.5 round down, and 0.5 or above rounds up. Thus round(2.4) = 2 and round(2.5) = 3. Unlike floor and ceiling, standard rounding minimizes distance to the nearest integer.
Practical Applications
The floor function appears across mathematics, computer science, finance, and engineering:
- Integer division: The quotient a ÷ b in integer arithmetic equals ⌊a/b⌋. For example, 17 ÷ 5 = ⌊3.4⌋ = 3 remainder 2.
- Modular arithmetic: The modulo operation is defined via floor: a mod b = a − b·⌊a/b⌋. For 17 mod 5: 17 − 5·3 = 2.
- Time conversion: Converting 150 minutes to hours: ⌊150 ÷ 60⌋ = ⌊2.5⌋ = 2 hours (with 30 minutes remaining).
- Data bucketing: Assigning value 73 to a bin of width 10: ⌊73 ÷ 10⌋ = 7, placing it in the 70–79 range.
- Pagination: Finding the page number for record 47 with 10 items per page: ⌊47 ÷ 10⌋ = 4 (zero-indexed page 4).
- Signal quantization: Analog-to-digital converters use floor to map continuous voltage levels to discrete binary values.
Step-by-Step Examples
Example 1: Positive Decimal
Find ⌊4.76⌋. The integers on either side are 4 and 5. Since 4 ≤ 4.76 < 5, the greatest integer not exceeding 4.76 is 4.
Example 2: Negative Decimal
Find ⌊−1.3⌋. The integers on either side are −2 and −1. Since −2 ≤ −1.3 < −1, the greatest integer not exceeding −1.3 is −2.
Example 3: Exact Integer
Find ⌊9⌋. Since 9 is already an integer, ⌊9⌋ = 9. The floor of any integer n equals n itself, satisfying the identity ⌊n⌋ = n for all n ∈ ℤ.
Reference