Math.floor() Method - Math Functions

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


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.


<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));


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.

Ask Questions

Ask Question