ceil Function returns the smallest integer greater than or equal to a number.
Syntax:
ceil(a numebr)
Description:
Because ceil is a static method of math, you always use it as Math.ceil(), rather than as a method of a Math object you created.
Example in HEAD Section
<html> <head> <title>Math.ceil function</title> <script language="javascript"> document.write("Pass value is -45.65 and return value is = " + Math.ceil(45.65) + "<br>"); document.write("Pass value is -45.65 and return value is = " + Math.ceil(-45.65)); </script> </head> </html> |
Example in BODY Section
<html> <head> <title>Math.ceil function</title> </head> <body> <script language="javascript"> document.write("Pass value is -45.65 and return value is = " + Math.ceil(45.65) + "<br>"); document.write("Pass value is -45.65 and return value is = " + Math.ceil(-45.65)); </script> </body> </html> |
OUTPUT
Pass value is -45.65 and return value is = 46
Pass value is -45.65 and return value is = -45
No comments:
Post a Comment