Math.floor()

In this chapter you will learn:

  1. How to use Math.floor() method

floor method

The Math.floor() method is the floor function. Math.floor() rounds numbers down to the nearest integer value.

<!DOCTYPE html><!-- j a  va 2  s.co  m-->
<html>
<head>
    <script type="text/javascript">
        document.writeln(Math.floor(25.9)); //25 
        document.writeln(Math.floor(25.5)); //25 
        document.writeln(Math.floor(25.1)); //25 
    </script>
</head>
<body>
</body>
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to use Math.round()
Home » Javascript Tutorial » Math
Math Object
Math min() and max()
Math.ceil()
Math.floor()
Math.round()
Math.random