Floor Function

Floor always rounds downward toward negative infinity, especially important for negative numbers.

🔢
Rounding Calculator
Enter a number and choose your rounding preferences
|
🧪 Quick Examples

What Is the Floor Function?

The floor function (⌊x⌋) returns the greatest integer less than or equal to a given number.

⌊3.2⌋ = 3
⌊3.9⌋ = 3
⌊3⌋ = 3
⌊−3.2⌋ = −4

Floor Function Definition

The mathematical definition of the floor function states that ⌊x⌋ is the greatest integer n such that nx.

This can also be expressed as an inequality: nx < n + 1, where n = ⌊x⌋.

In simple terms, this means if a number has any fractional part, you move down to the nearest integer below it on the number line. If it is already an exact integer, it does not change.

Floor Function Notation

The standard notation for the floor function uses special brackets that are missing their top horizontal bars: ⌊x⌋.

  • Floor brackets: ⌊x⌋ (Square brackets missing the top part, visually resembling a "floor").
  • Ceiling brackets: ⌈x⌉ (Square brackets missing the bottom part, visually resembling a "ceiling").

Do not confuse floor brackets with ordinary parentheses (x) or standard square brackets [x], as those have different mathematical meanings.

How Does the Floor Function Work?

Applying the floor function follows a clear directional rule on the number line:

1

Start with the input number

Locate the given number on the number line.

2

Identify the integers

Look at the integers immediately above and below the number.

3

Check for an exact integer

If the input is already an integer, keep it unchanged.

4

Select the greatest integer

Select the greatest integer that is less than or equal to the input. For negative numbers, remember that floor moves toward negative infinity.

Examples

Positive Numbers:

  • ⌊2.1⌋ = 2
  • ⌊2.9⌋ = 2
  • ⌊7.01⌋ = 7

Integers:

  • ⌊4⌋ = 4

Negative Numbers:

  • ⌊−2.1⌋ = −3
  • ⌊−2.9⌋ = −3

What Does "Toward Negative Infinity" Mean?

Negative infinity is a direction on the number line, always moving to the left. When the floor function is applied to any non-integer value, it pushes the value strictly in that leftward direction.

For positive values, moving to the left means decreasing the magnitude:

  • 2.1 → 2
  • 2.9 → 2

For negative values, moving to the left means moving further away from zero (increasing the magnitude in the negative direction):

  • −2.1 → −3
  • −2.9 → −3

Do not simply think of the floor function as "rounding down" without knowing what "down" means. In mathematics, "down" means "toward negative infinity", not "toward zero."

Floor Function With Negative Numbers

Negative numbers commonly cause confusion with the floor function. A frequent mistake is assuming that ⌊−2.1⌋ equals −2. However, ⌊−2.1⌋ = −3.

Why? Because the rule is to find the greatest integer less than or equal to the input.

On a number line, −3 is less than −2.1, but −2 is greater than −2.1. Since the floor function requires an integer less than or equal to the input, it must move to −3:

−3 ≤ −2.1 < −2
Therefore, ⌊−2.1⌋ = −3

Other examples:

  • ⌊−2.9⌋ = −3
  • ⌊−3⌋ = −3

Floor Function of an Integer

When the input is already an exact integer, the floor function leaves the value completely unchanged.

  • ⌊1⌋ = 1
  • ⌊0⌋ = 0
  • ⌊−1⌋ = −1
  • ⌊10⌋ = 10

Floor Function of Fractions & Decimals

For decimal numbers and fractions, the floor function effectively removes the fractional part for positive numbers, but for negative numbers, it drops to the next lower integer.

Fractions:

  • ⌊7/3⌋ = 2
  • ⌊11/4⌋ = 2
  • ⌊−7/3⌋ = −3
  • ⌊−11/4⌋ = −3

Positive Decimals:

  • ⌊1.1⌋ = 1
  • ⌊1.5⌋ = 1
  • ⌊1.99⌋ = 1
  • ⌊3.001⌋ = 3

Negative Decimals:

  • ⌊−1.1⌋ = −2
  • ⌊−1.99⌋ = −2
  • ⌊−3.001⌋ = −4

Floor Function to Decimal Places

Sometimes you need to apply the floor function to a specific number of decimal places (e.g., floor to 2 decimal places). This is done using a scaling method: multiply by a power of 10, apply the floor function, and divide back.

  • Floor 2.349 to 2 decimal places: ⌊2.349 × 100⌋ / 100 = ⌊234.9⌋ / 100 = 234 / 100 = 2.34
  • Floor 2.341 to 1 decimal place: ⌊2.341 × 10⌋ / 10 = ⌊23.41⌋ / 10 = 23 / 10 = 2.3
  • Floor 7.999 to 2 decimal places: 7.99

For negative numbers, the value still moves toward negative infinity:

  • Floor −2.341 to 2 decimal places: ⌊−2.341 × 100⌋ / 100 = ⌊−234.1⌋ / 100 = −235 / 100 = −2.35

Floor Function Examples

Input Floor Explanation
2.122 is the greatest integer ≤ 2.1
2.522 is the greatest integer ≤ 2.5
2.922 is the greatest integer ≤ 2.9
33Input is already an integer
−2.1−3−3 is the greatest integer ≤ −2.1
−2.5−3−3 is the greatest integer ≤ −2.5
−2.9−3−3 is the greatest integer ≤ −2.9
−3−3Input is already an integer

Floor Function vs Ceiling Function

The ceiling function is the exact opposite of the floor function. The floor function always moves toward negative infinity, while the ceiling function always moves toward positive infinity.

Input Floor Ceiling
2.323
2.823
−2.3−3−2
−2.8−3−2
−3−3−3

Floor Function vs Rounding

Nearest rounding (Round Half Up) selects the closest integer. The floor function does not care which integer is closer; it always selects the greatest integer less than or equal to the input.

  • 2.3: Floor → 2 | Nearest rounding → 2
  • 2.7: Floor → 2 | Nearest rounding → 3
  • −2.3: Floor → −3 | Nearest rounding → −2
  • −2.7: Floor → −3 | Nearest rounding → −3

Floor Function vs Integer Part

The integer part function simply extracts the integer digits of a number, stripping away the decimal. This moves the value strictly toward zero, which creates a critical difference for negative numbers.

  • 2.7: Floor = 2 | Integer part = 2
  • −2.7: Floor = −3 | Integer part = −2

This reinforces the distinction that floor is a directional operation (toward negative infinity), not a simple truncation.

Floor Function vs Truncation

Truncation simply chops off (removes) the fractional part of a number, moving the value strictly toward zero. Floor moves toward negative infinity. This difference becomes important with negative numbers.

  • 2.8: Floor → 2 | Truncate → 2
  • −2.8: Floor → −3 | Truncate → −2

Floor Function vs Round Down

The term "round down" can be ambiguous. In strict mathematical terminology, "round down" is usually synonymous with the floor function (moving toward negative infinity). However, in some financial contexts, "round down" means truncation (moving toward zero).

For example, with −2.7, floor yields −3, but truncation yields −2.

Floor Function Graph

The graph of the floor function, y = ⌊x⌋, is a step-shaped graph (also known as a step function). It remains perfectly flat for all values between integers, and then jumps up at each integer.

For each integer n where nx < n + 1, the floor value is exactly n.

  • For 0 ≤ x < 1, ⌊x⌋ = 0
  • For 1 ≤ x < 2, ⌊x⌋ = 1
  • For −1 ≤ x < 0, ⌊x⌋ = −1

On the graph, the left end of each horizontal step is a closed circle (meaning it includes the integer), and the right end is an open circle (meaning it does not include the next integer).

Floor Function Formula

The floor function is formally defined in set notation as:

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

In simple language, this formula says: "Look at the set of all integers (ℤ) that are less than or equal to x, and pick the maximum (max) value from that set."

Properties of the Floor Function

  • Identity for integers: ⌊x⌋ = x when x is an integer.
  • Bounds: x − 1 < ⌊x⌋ ≤ x for non-integer x.
  • Symmetry with ceiling: ⌊x⌋ = −⌈−x⌉.
  • Addition of an integer: ⌊x + n⌋ = ⌊x⌋ + n for any integer n.

Where Is the Floor Function Used?

The floor function has massive importance in real-world scenarios, particularly when partial items cannot be counted or used.

  • Completed units: If you have 29 items and each complete group requires 10 items, the number of completely filled groups is ⌊29 / 10⌋ = 2.
  • Computer science: Finding array indices, converting floating-point coordinates to pixel coordinates on a screen.
  • Resource allocation: Determining how many full hours of a service you can afford with a given budget.
  • Data processing: Grouping data into specific time bins (e.g., grouping logs by the hour).

Floor Function in Programming

Floor Function in Python

import math
math.floor(2.7) # Returns 2
math.floor(-2.7) # Returns -3

Floor Function in JavaScript

Math.floor(2.7); // Returns 2
Math.floor(-2.7); // Returns -3

Floor Function in Java

Math.floor(2.7); // Returns 2.0 (returns a double)
Math.floor(-2.7); // Returns -3.0

Floor Function in C#

Math.Floor(2.7); // Returns 2
Math.Floor(-2.7); // Returns -3

Floor Function in Excel

Excel has multiple floor functions. FLOOR.MATH(number, significance, mode) is the most robust, always rounding toward negative infinity by default. FLOOR(number, significance) can error on negative numbers if signs do not match.

Floor Function in Mathematics

Beyond basic arithmetic, the floor function is heavily utilized in advanced mathematics:

  • Number theory: Used in formulas involving primes and divisibility.
  • Modular arithmetic: The modulo operation is often defined as a mod n = a − n × ⌊a / n⌋.
  • Discrete mathematics: Transforming continuous domain functions into discrete, integer-valued functions.

Common Floor Function Mistakes

  • Confusing floor with truncation: Truncation cuts off the decimal (moving toward zero). Floor moves toward negative infinity. Correction: For negative numbers, floor makes the magnitude larger, truncation makes it smaller.
  • Forgetting negative numbers move toward negative infinity: Many mistakenly believe ⌊−2.7⌋ is −2. Correction: It is −3.
  • Confusing floor with ceiling: Correction: Floor goes left on the number line; ceiling goes right.
  • Using floor when nearest rounding is needed: Floor ignores the closest integer. Correction: If you need the closest value to 2.9, use nearest rounding to get 3, not floor.

Floor Function Quick Reference

The floor function returns the greatest integer less than or equal to the input.

Input Floor
2.12
2.92
33
−2.1−3
−2.9−3
−3−3

Floor Function Practice

Test your understanding of the floor function with these examples. Click on a question to reveal the answer.

⌊2.4⌋ = ?
Answer: 2 (Greatest integer ≤ 2.4)
⌊7.99⌋ = ?
Answer: 7 (Floor ignores the closeness to 8)
⌊−2.4⌋ = ?
Answer: −3 (Moves toward negative infinity)
⌊−7.99⌋ = ?
Answer: −8 (Moves toward negative infinity)
⌊5⌋ = ?
Answer: 5 (Integers remain unchanged)
⌊0.9⌋ = ?
Answer: 0
⌊−0.1⌋ = ?
Answer: −1
⌊29 / 10⌋ = ?
Answer: 2 (Since 2.9 floors to 2)
Floor 5.129 to 2 decimal places?
Answer: 5.12
Floor −5.121 to 2 decimal places?
Answer: −5.13