English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
TheMath.floor()The method returns the largest integer less than or equal to the given floating-point number.
If the passed parameter is an integer, the value will remain unchanged.
Since floor() is a static method of Math, you always use it asMath.floor(), rather than as a method of the Math object created.
Math.floor(x)
Math.floor(3.14); // 3 Math.floor(.)95);// 0 Math.floor(5); // 5 Math.floor(-18);// -18 Math.floor(-0.72); // -1Test and See‹/›
All browsers fully support the Math.floor() method:
Method | |||||
Math.floor() | Yes | Yes | Yes | Yes | Yes |
Parameter | Description |
---|---|
x | Value |
Return Value: | The largest integer less than or equal to the specified number |
---|---|
JavaScript Version: | ECMAScript 1 |