JavaScript Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Java-Script Tutorial
Introduction Introduction
Variables Variables
Operators Operators
Statements Statements
Loops Loops
Functions Functions
Objects Objects
Arrays Arrays
Cookies JS Cookies
Browser Objects Browser Objects
Form DOM Form DOM
Style Objects DOM Style Objects
Forums Ask Your Doubts
Scraps More about Javascript
Feedback Feedback
 




Math.floor() Method - Math Functions


Tutorials Javascript

Topic

Math.floor() method of Math Functions in Javascript.
How to Round off to the lower value of a number in javascript?



Explanation

Object: Math

Method: Math.floor()

Description:To get the number rounded to the immediate lower value. The below example will round off a positve or a negative number to the lower value using math functions.

Example:
<script type="text/javascript">
document.write('Floor value of .50 is::'+Math.floor(.50) + "<br/>");
document.write('Floor value of 2.6 is::'+Math.floor(2.6) + "<br/>");
document.write('Floor value of -2.1 is::'+Math.floor(-2.1));
</script>
Result:


In the above example,
  • Math.floor() method is used to round off the numbers to next lower values.
  • So for the value .50 it returns 0, 2.6 returns 2.
  • For a negative number -2.1 Math.floor() method returns -3.






  • A Note
    Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

    Other Links

    web hosting