Home  >  Article  >  Web Front-end  >  How to use floor method

How to use floor method

不言
不言Original
2019-02-01 17:13:463461browse

The floor() method in How to use floor method is used to round the number passed as a parameter to the nearest integer in the downward direction, that is, towards the smaller value. In this article, we will take a look at the floor() method. specific usage.

How to use floor method

The basic syntax of the floor() method:

Math.floor( x ) ;

x represents a number and returns the largest integer less than or equal to the number x.

Let’s take a look at the specific example

The code is as follows

<!DOCTYPE html>
<html>
   <head>
      <title></title>
   </head>
   <body> 
<script type="text/javascript"> 
    document.write(Math.floor(-2)+"<br/>");  
    document.write(Math.floor(-2.56)+"<br/>");    
    document.write(Math.floor(2.56)+"<br/>");   
     document.write(Math.floor(7.2+9.3));       
</script> 
   </body>
</html>

The effect of running on the browser is as follows: the output of all numbers will be less than or equal to it Maximum integer.

How to use floor method

This article ends here. For more exciting content, you can pay attention to other related column tutorials on the PHP Chinese website! ! !

The above is the detailed content of How to use floor method. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn