Floor Function
floor(x) is the greatest integer less than or equal to x. It rounds down toward negative infinity. Compare with ceiling, round, and fractional part.
Did our AI summary help? Let us know.
Integer division: a div b = floor(a/b) in many languages. floor(โ2.3) = โ3, not โ2. Floor always rounds toward โโ. Fractional part {x} = x โ floor(x) is used in hashing.
Ready to run the numbers?
Why: The floor function is fundamental in integer division, array indexing, and modular arithmetic.
How: For positive x, floor truncates the decimal. For negative x, floor rounds toward โโ (e.g., floor(โ2.3) = โ3).
Run the calculator when you are ready.
Enter Number
Floor vs Ceiling vs Round
Integer vs Fractional
๐ Step-by-Step Breakdown
For educational and informational purposes only. Verify with a qualified professional.
๐งฎ Fascinating Math Facts
floor(3.7) = 3 and ceil(3.7) = 4. For integers, floor(n) = ceil(n) = n.
โ Basics
Used in integer division: a div b = floor(a/b) in many programming languages.
โ Programming
๐ Key Takeaways
- โข floor(x) = greatest integer โค x. Rounds down toward negative infinity
- โข For positive x: floor gives the integer part; for negative: floor is less than x
- โข ceil(x) = least integer โฅ x. floor(-x) = -ceil(x)
- โข Fractional part: {x} = x - floor(x), always in [0, 1) for positive x
๐ก Did You Know?
๐ How It Works
The floor function maps x to the greatest integer less than or equal to x. For positive numbers, it truncates the decimal. For negative numbers, it rounds toward negative infinity (e.g., floor(-2.3) = -3).
๐ Worked Example: floor(-2.3)
Step 1: -2.3 lies between -3 and -2
Step 2: Greatest integer โค -2.3 is -3
Result: โ-2.3โ = -3
โ ๏ธ Common Mistakes to Avoid
- floor(-2.3) = -2: Wrong. floor(-2.3) = -3. Floor rounds toward -โ.
- Confusing with trunc: trunc(-2.3) = -2; floor(-2.3) = -3.
- Fractional part for negatives: {x} = x - floor(x) can exceed 1 for negative x.
๐ฏ Expert Tips
๐ก Negative numbers
floor(-2.3) = -3, not -2. Floor always rounds toward -โ.
๐ก Integer division
In Python, a // b = floor(a/b). JavaScript: Math.floor(a/b).
โ FAQ
What is the floor function?
floor(x) is the greatest integer less than or equal to x. It rounds down toward negative infinity.
How does floor differ from trunc?
For positive x they match. For negative: floor(-2.3) = -3, trunc(-2.3) = -2.
What is the fractional part?
{x} = x - floor(x). For 3.7, fractional part is 0.7.
When is floor used in programming?
Integer division (a // b), array indexing, pagination, and hashing.
What is the relationship between floor and ceiling?
floor(-x) = -ceil(x). For any real x: floor(x) โค x โค ceil(x).
โ ๏ธ Disclaimer: For educational use. Uses JavaScript Math.floor which has floating-point precision limits for very large numbers.
Related Calculators
Ceiling Function Calculator
Calculate the ceiling function of any real number. The ceiling is the smallest integer greater than or equal to x. Compare with floor, fractional part, and...
MathematicsQuadratic Equation Calculator
Solve quadratic equations axยฒ + bx + c = 0. Find real and complex roots, discriminant analysis, vertex coordinates, and step-by-step solutions with graph...
MathematicsArithmetic Decimal To Percent Calculator
Arithmetic Decimal To Percent Calculator - Calculate and learn about arithmetic concepts
MathematicsRoot Mean Square Calculator
Calculate RMS = sqrt(mean of xยฒ). AC voltage equivalent, compare with arithmetic mean. Step-by-step for statistics and signal processing.
MathematicsRatio Calculator
Simplify ratios, scale ratios to find equivalent ratios, and solve proportions. Supports 2-part and 3-part ratios with step-by-step solutions and GCD...
MathematicsRelatively Prime Calculator
Check if two or more integers are relatively prime (coprime). GCD = 1 means no common factors. Euler totient, Euclidean algorithm, coprime pairs.
Mathematics