JavaScript Math Object : floor()

The floor() method returns the value of given number rounded down to its nearest integer. Syntax :
  Math.floor( number );
Example :
<script>
  var x = -10.89;
  var y = Math.floor(x);
  document.write("floor(-10.89) : " + y + "<br/>");
  var x = -20.675;
  var y = Math.floor(x);
  document.write("floor(-20.675) : " + y + "<br/>");
  var x = 30.23;
  var y = Math.floor(x);
  document.write("floor(30.23) : " + y + "<br/>");
  var x = 15.75;
  var y = Math.floor(x);
  document.write("floor(15.75) : " + y + "<br/>");
 </script>
Output :



Next Topic :