freeCodeCamp/guide/english/javascript/standard-objects/math/math-floor/index.md

795 B

title
Math Floor

Math Floor

Math.floor() is a method of the Math standard object that rounds a given number downwards to the next integer. Take note that for negative numbers this means that the number will get rounded "away from 0" instead of to the number of smaller absolute value since Math.floor() returns the largest integer less than or equal to the given number.

Examples

Math.floor(0.9)  //  0
Math.floor(1.3)  //  1
Math.floor(0.5)  //  0
Math.floor(-0.9) // -1
Math.floor(-1.3) // -2

More Information: