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