In JavaScript, ceil means "rounding up". It is a built-in function used to round numbers up to the nearest integer. The syntax format is "Math.ceil(x)", and the parameter " x" must be a numeric value; the function's return value is the nearest integer greater than or equal to the parameter "x".
The operating environment of this tutorial: windows7 system, javascript version 1.8.5, Dell G3 computer.
ceil() is a built-in function of "rounding up" in JavaScript.
ceil() function rounds a number up to the nearest integer and returns the result. If the argument passed is an integer, the value will not be rounded.
The ceil() method performs rounding up calculation. It returns the integer that is greater than or equal to the function parameter and is the closest to it.
Syntax:
Math.ceil(x)
x: Required. Must be a numeric value.
Return value: Number type, which is greater than or equal to x and the closest integer to it.
Example:
console.log(Math.ceil(0.60)); console.log(Math.ceil(0.40)); console.log(Math.ceil(5)); console.log(Math.ceil(5.1)); console.log(Math.ceil(-5.1)); console.log(Math.ceil(-5.9));
[Recommended learning: javascript advanced tutorial]
The above is the detailed content of What does ceil mean in javascript. For more information, please follow other related articles on the PHP Chinese website!