Last updated October 4, 2026 · Report an error
The floor function, written ⌊x⌋, rounds any real number down to the nearest integer — always toward negative infinity, never toward zero. It's one of the most fundamental building-block functions in discrete mathematics and computer science, showing up anywhere a continuous or fractional value needs to be converted into a whole-number index, bucket, or count, such as computing which page a list item falls on, or which array slot a value maps to. This tool calculates ⌊x⌋ for any real-number input, including negative numbers and integers, and is especially useful for confirming the correct behavior with negative inputs, which is exactly where floor is most often confused with simple truncation.
How it works
The floor of x is defined as the largest integer that is less than or equal to x. For a positive non-integer value, this simply means dropping the fractional part (rounding down toward zero). For a negative non-integer value, it means rounding away from zero, toward negative infinity — since the "largest integer ≤ x" for a negative decimal is actually more negative than the value itself. For a number that is already an integer, the floor is that same integer, since it already satisfies "the largest integer ≤ itself."
- Enter number.
- Click Calculate to see your results.
Examples
A positive decimal
⌊4.8⌋ = 4, since 4 is the largest integer that is ≤ 4.8.
A negative decimal
⌊−4.2⌋ = −5, since −5 is the largest integer that is ≤ −4.2 (rounding toward negative infinity, not toward zero).
An exact integer input
⌊7⌋ = 7, since an integer is already the largest integer less than or equal to itself, with no rounding needed at all.
Who should use it
- Computer science indexing and bucketing calculations.
- Mathematics coursework on floor/ceiling functions.
- Verifying floor behavior for negative-number edge cases in code.
Industry applications
- Computer science and programming
- Mathematics education
Advantages
- Correct handling of negative numbers, unlike naive truncation.
- Works for any real-valued input.
- A precise, unambiguous mathematical definition.
Limitations
- Only computes the floor itself — for the complementary ceiling function use the Ceiling Function Calculator.
Common mistakes to avoid
- Confusing floor with truncation — for negative numbers, truncating toward zero gives a different (larger) result than the true floor.
- Assuming floor and standard "round to nearest" rounding behave the same way — they diverge whenever the decimal portion would normally round up.
- Forgetting that many programming languages' built-in integer division truncates toward zero rather than performing a true floor operation for negative numbers.
Best practices
- Use floor whenever you need "round down, no matter the sign" behavior, such as computing array indices or bucket assignments.
- Explicitly verify your programming language's floor/division function behavior with a negative-number test case before relying on it.
- Use the Ceiling Function Calculator alongside this one when you need to compare both rounding directions for the same value.
Tips
- If you need "round down" behavior in code, confirm your language's division/rounding function actually implements floor and not truncation for negative numbers.
- Remember the relationship ⌈x⌉ = ⌊x⌋ + 1 for any non-integer x if you need both values.