Mega Code Archive

 
Categories / JavaScript Tutorial / Math
 

Math ceil()

Syntax math.ceil(num) The ceil() method calculates the smallest integer that is greater than or equal to the number passed in as a parameter. <html>     <body>     <title>Example of the ceil() method</title>     <script language="JavaScript">     <!--     function doMath(){         var inputNum=document.form1.input.value;         var result = Math.ceil(inputNum);         document.form1.answer.value = result;     }     -->     </script>     <form name=form1>     This example calculates ceiling of the entered number.     <br><br>     Enter First Number:     <input type="text" name="input" size=10>     <input type="button" value="Calculate" onClick='doMath()'>     <br>     The Ceil output is:     <input type="text" name="answer" size=10>     </form>     </body>     </html>