Math.floor() : floor « Math « JavaScript Tutorial






Syntaxmath.floor(num)
DescriptionGet the largest integer number, which is equivalent to or less than the number passed as the parameter.


<html>
    <body>
    <script language="JavaScript">
    <!--
    function doMath(){
        var inputNum=document.form1.input.value;
        var result = Math.floor(inputNum);
        document.form1.answer.value = result;
    }
    -->
    </script>
    <form name=form1>
    This example calculates the floor of the number entered.
    <br><br>
    Enter First Number:
    <input type="text" name="input" size=10>
    <input type="button" value="Calculate" onClick='doMath()'>
    <br>
    The floor is:
    <input type="text" name="answer" size=10>
    </form>
    </body>
    </html>








9.11.floor
9.11.1.Math.floor()