Home >Web Front-end >JS Tutorial >Introduction to using JavaScript Math.ceil() function_Basic knowledge
Math.ceil(x) -- Returns the smallest integer (rounding function) that is greater than or equal to the numeric parameter, and rounds the number up
ceil is the abbreviation of ceiling, which means "upper limit" in Chinese
Reference URL: http://www.dreamdu.com/javascript/Math.ceil/
ceil function syntax
Math.ceil(x);
ceil function parameter
x -- a number of type number
ceil function return value
Return the smallest integer greater than or equal to (-5.99));
document.write(Math.ceil(1.01));
document.write(Math.ceil(-1.01)); Result:
6
-5
2
-1