Ceiling and floor

suggest change

ceil()

Math.ceil() rounds a number toward +∞ to an integer and returns that value.

Syntax:

Math.ceil(n);

Example:

console.log(Math.ceil(0.60)); //  1
console.log(Math.ceil(0.40)); //  1
console.log(Math.ceil(5.1));  //  6
console.log(Math.ceil(-5.1)); // -5
console.log(Math.ceil(-5.9)); // -5

floor()

Math.floor() rounds a number toward −∞ to an integer and returns that value.

Syntax:

Math.floor(n);

Example:

console.log(Math.floor(0.60)); //  0
console.log(Math.floor(0.40)); //  0
console.log(Math.floor(5.1));  //  5
console.log(Math.floor(-5.1)); // -6
console.log(Math.floor(-5.9)); // -6

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents