[an error occurred while processing this directive]

JavaScript floor method


JavaScript floor method is used to achieve the next complete number in the downward position. For example if we apply the floor method on the number like "1.2213" then it will return the floor value as "1" and if we will provide some negative number as "-4.463465" then it will return the number as "-5".


   Math.floor( number) ;

Description of code: 

We have created an input text box in which user can provide the number of which we have to calculate the floor value. When user clicks on the button "Show Floor value" it calls the method callFloor() . In the callFloor() method it takes the number from the text box and shows the floor value in the alert message by using the alert() method. Here is the full example code of floorExample.html as follows:

function callFloor(){
var val= document.getElementById("txt").value;
<div style="background: #cf2255; width:'100%';" align="center">
<font color="#ffffcc" size="12pt">
<b>Floor Example</b>
<div style="background: #ffffcc; width:'100%';" align="center">
Input any decimal number(9999.9999) :<input type="text" id="txt" value=""/>
<button onclick="callFloor();">Show Floor Value</button>

Output :

Input any number to find its floor value.

Download Source Code


[an error occurred while processing this directive]