Tutorial by Examples: ceil

In addition to the built-in round function, the math module provides the floor, ceil, and trunc functions. x = 1.55 y = -1.55 # round to the nearest integer round(x) # 2 round(y) # -2 # the second argument gives how many decimal places to round to (defaults to 0) round(x, 1) ...
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....
Round a decimal number to an integer value For exact numeric values (e.g. DECIMAL): If the first decimal place of a number is 5 or higher, this function will round a number to the next integer away from zero. If that decimal place is 4 or lower, this function will round to the next integer value cl...
The CEILING function rounds a number up, away from zero, to the nearest multiple of significance. The FLOOR function does the same by rounds the number down towards zero. An example of when CEILING could be be used is if you want to avoid using pennies in your prices and your product is priced at $...

Page 1 of 1