Ceiling and floor

suggest change

ceil()

The ceil() method rounds a number upwards to the nearest integer, and returns the result.

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()

The floor() method rounds a number downwards to the nearest integer, and returns the result.

Syntax:

Math.floor(n);

Example:

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

Feedback about page:

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


Arithmetic Math:
* Ceiling and floor

Table Of Contents
11 Arrays
12 Objects
14 Classes
16 Map
17 Set
18 Arithmetic Math
24 Loops
27 Date
29 Scope
30 AJAX
35 Cookies
41 JSON
44 Fetch
45 Modules
46 Screen
64 Console
68 Symbols
73 Modals
76 Events
86 Proxy
89 WeakMap
90 WeakSet
102 Tilde