Latest Tutorials| Questions and Answers|Ask Questions?|Site Map

Home Javascript JavaScript floor method

Related Tutorials


Share on Google+Share on Google+

JavaScript floor method

JavaScript floor method is used to achieve the next complete number in the downward position.

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



If you enjoyed this post then why not add us on Google+? Add us to your Circles

Liked it!  Share this Tutorial

Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: January 29, 2009

Related Tutorials

Discuss: JavaScript floor method  

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image