Home  >  Article  >  Web Front-end  >  How to use sqrt function

How to use sqrt function

不言
不言Original
2019-02-16 15:50:00108662browse

The sqrt function in How to use sqrt function is used to return the square root of a number, which is the square root. In the following article, we will take a closer look at how to use the sqrt function.

How to use sqrt function

Let’s take a look at the basic syntax of the sqrt function

Math.sqrt(value)

The square root number needs to be calculated.

Returns the square root of the number passed as argument.

It should be noted that:

1. A non-numeric string passed as a parameter returns NaN

2. An array of more than 1 integer passed as a parameter returns NaN

3. Negative numbers passed as parameters return NaN

4. Empty strings passed as parameters return NaN

5. Empty arrays passed as parameters return NaN

Let’s look at the specific examples

The code is as follows

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title></title>
</head>
<body>
<script type="text/javascript"> 
    document.write(Math.sqrt(2)+"<br>");  
    document.write(Math.sqrt(2.56)+"<br>");  
    document.write(Math.sqrt(-2)+"<br>"); 
     document.write(Math.floor("How to use sqrt function")+"<br>");     
      document.write(Math.floor(7.2+9.3));           
</script> 
</body>
</html>

The execution results are as follows

1.4142135623730951
1.6
NaN
NaN
16

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

The above is the detailed content of How to use sqrt function. 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