Floor Function Calculator
Enter any real number to compute its floor value, the largest integer that is less than or equal to it. The calculator also shows the ceiling, standard rounding, truncation, and fractional part alongside a step-by-step breakdown so you can see exactly how the result is reached. Works for positive numbers, negative numbers, fractions, and integers alike.
Formula
Worked example
For x = -1.3: the integers below -1.3 are ..., -3, -2, and the largest one that is still <= -1.3 is -2. So floor(-1.3) = -2. The fractional part is -1.3 - (-2) = 0.7. The ceiling is -1 because -1 is the smallest integer >= -1.3.
What is the floor function?
The floor function maps any real number x to the largest integer that is less than or equal to x. In mathematical notation it is written with special bracket symbols, often called "floor brackets": the integer directly to the left of x on the number line. For positive numbers this is simply the integer part, obtained by dropping everything after the decimal point. For example, floor(3.7) = 3 and floor(3) = 3. The behavior for negative numbers is where students most often get tripped up: floor(-1.3) = -2, not -1, because -2 is the largest integer that is still to the left of -1.3 on the number line. Think of it as "always rounding down," where "down" means toward negative infinity, not toward zero.
Floor vs. ceiling, truncation, and rounding
The floor function is one of four closely related integer-rounding operations. The ceiling function is the mirror image: ceil(x) is the smallest integer greater than or equal to x, so ceil(3.7) = 4 and ceil(-1.3) = -1. Truncation removes the fractional part and rounds toward zero: trunc(3.7) = 3 and trunc(-1.3) = -1. Standard rounding uses the nearest integer, going up at exactly 0.5: round(3.7) = 4 and round(-1.3) = -1. For positive numbers, floor and truncation give the same result. For negative non-integers they differ: floor(-1.3) = -2 but trunc(-1.3) = -1. A useful identity connects floor and ceiling: ceil(x) = -floor(-x), and equivalently floor(x) = -ceil(-x). Another important identity is the integer shift: floor(x + n) = floor(x) + n for any integer n, which lets you shift the argument without changing the fractional structure.
Real-world uses of the floor function
The floor function appears throughout computing, finance, and everyday problem solving. In integer division, most programming languages define quotient = floor(a / b) when dividing a by b, which determines how many whole groups fit inside a larger quantity. Scheduling problems use floor to count how many complete weeks or months have elapsed since a date. In finance, floor is used when interest is credited only for complete periods. A floored mortgage rate is one that cannot drop below a set minimum, borrowing the same directional concept. In computer graphics, floor converts continuous coordinates to discrete pixel indices. The modulo operation is defined as: a mod b = a - b * floor(a / b), so any code that uses the remainder depends on floor. Number theory uses floor extensively in counting divisors, summing series, and analyzing prime distributions.
Key properties and identities
Several identities make the floor function tractable in proofs and algorithms. Idempotency states that applying floor twice gives the same result as once: floor(floor(x)) = floor(x). The fractional part of x is defined as frac(x) = x - floor(x), which always lies in the interval [0, 1). For any integer n, floor(x + n) = floor(x) + n, so adding an integer to the argument shifts the result by the same integer. The inequality x - 1 < floor(x) is always strictly true, and floor(x) is always <= x. The negation identity, floor(-x) = -ceil(x), pairs every floor calculation with a ceiling one: knowing one gives you the other for free. The floor function is not continuous because it jumps by 1 at every integer, and it is not one-to-one because every real number in the interval [n, n+1) maps to the same integer n.
Floor function properties and identities
| Property | Formula | Example (x = 3.7) |
|---|---|---|
| Definition | floor(x) = largest integer <= x | floor(3.7) = 3 |
| Idempotency | floor(floor(x)) = floor(x) | floor(3) = 3 |
| Integer shift | floor(x + n) = floor(x) + n | floor(3.7 + 2) = 5 |
| Inequality | x - 1 < floor(x) <= x | 2.7 < 3 <= 3.7 |
| Fractional part | frac(x) = x - floor(x) | 3.7 - 3 = 0.7 |
| Negation identity | floor(-x) = -ceil(x) | floor(-3.7) = -ceil(3.7) = -4 |
| Ceiling relation | ceil(x) = -floor(-x) | ceil(3.7) = -floor(-3.7) = 4 |
| For integers n | floor(n) = n | floor(3) = 3 |
| Non-decreasing | if x <= y then floor(x) <= floor(y) | floor(3.7) <= floor(4.2) |
Key mathematical properties of the floor function, valid for any real x and any integer n.
Frequently asked questions
What is floor(-1.3)?
floor(-1.3) = -2. The floor function always rounds toward negative infinity, not toward zero. Because -2 is the largest integer that is still less than or equal to -1.3, the answer is -2. Students often guess -1 by analogy with dropping the decimal, but that logic only works for positive numbers.
What is the difference between floor and truncation?
For positive numbers they are the same: both give the integer part by discarding the decimal. For negative numbers they differ. Truncation rounds toward zero: trunc(-1.3) = -1. Floor rounds toward negative infinity: floor(-1.3) = -2. For any x >= 0 the results are identical; the difference only arises when x is a negative non-integer.
How do I write the floor function in LaTeX?
Use the commands \lfloor and \rfloor around the argument: \lfloor x \rfloor renders as the floor-bracket notation. Many LaTeX environments also support the mathtools package which provides \lfloor and \rfloor with automatic sizing. In programming, most languages provide Math.floor() in JavaScript/Java, math.floor() in Python, or FLOOR() in Excel.
Is the floor function the same as rounding down?
Yes, as long as "down" means toward negative infinity. The phrase "round down" in everyday speech usually means toward zero, which is truncation, not floor. For positive numbers the distinction does not matter. For negative numbers, floor(-2.5) = -3 (toward negative infinity), while truncation gives -2 (toward zero). The floor function is more commonly used in mathematics and programming because it has cleaner algebraic properties.
What is the fractional part of a number?
The fractional part of x is x minus its floor: frac(x) = x - floor(x). It is always in the range [0, 1) regardless of whether x is positive or negative. For example, frac(3.7) = 3.7 - 3 = 0.7, and frac(-1.3) = -1.3 - (-2) = 0.7. Note that both 3.7 and -1.3 have the same fractional part of 0.7 under this definition.
How does floor division work in programming?
Floor division divides two numbers and applies the floor function to the result. In Python the // operator performs floor division: 7 // 2 = 3 and -7 // 2 = -4 (because floor(-3.5) = -4). In JavaScript Math.floor(7 / 2) = 3. Floor division is closely tied to the modulo operator: a = (a // b) * b + (a % b), where % is the remainder with the sign matching the divisor. This definition ensures non-negative remainders when b is positive.