0% found this document useful (0 votes)
12 views6 pages

Math Methods

Maths methods to use.

Uploaded by

duharpita
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views6 pages

Math Methods

Maths methods to use.

Uploaded by

duharpita
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Math Methods

[Link](x,y)
The [Link](x,y) method is used to return the value of x to the power y

<html>
<body>
<h2>The pow() function</h2>
<p>This method returns the result of x raised to power y</p>
<script>
function powerFunction(p1, p2) {
return [Link](p1,p2);
}
[Link]( powerFunction(4, 3))
</script>
</body>
</html>

The [Link]( ) method returns the square root of x

<html>
<body>
<h2>The sqrt() method</h2>
<p>This method returns the square root of the value passed</p>
<script>
function myFunction(p1) {
return [Link](p1);
}
[Link]( myFunction(64))
</script>
</body>
</html>
[Link]() and [Link]() methods
<html>
<head>
<title>The [Link] and [Link]()</title>
<p>Click the button to round up the number</p>
<button onclick="roundup()">Round Up</button>
<p>Click the button to round down the number</p>
<button onclick="roundown()">Round Down</button>
<p>The [Link]() function returns the integer greater than or equal to the provided
number.</p>
<p id="msg1"></p>
<p>The [Link]() function returns the integer smaller than or equal to the provided
number.</p>
<p id="msg2"></p>
<script>
function roundup(){
[Link]("msg1").innerHTML = [Link](53.478);}
function roundown(){
[Link]("msg2").innerHTML = [Link](53.478);}
</script>
</head>
</html>

[Link]() and [Link]() methods


<html>
<head>
<title>Max and Min Methods</title>
<p>The <code>[Link]()</code> function returns the largest of zero or more
numbers.</p>
<p>The <code>[Link]()</code> function returns the smallest of zero or more
numbers.</p>
<script>
[Link]([Link](-8,9,34,52,18,23),"<Br>")
[Link]([Link](-8,9,34,52,18,23))
</script></head></html>
[Link] property

<!DOCTYPE html>
<html><head>
<title>[Link]</title>
<p><code>[Link]</code> is a static property that represents the ratio of the
circumference of a circle to its diameter.
<br> Therefore the result will always the same number, regardless of the circle's size.</p>
<p id="msg"></p>
<script>
[Link]("msg").innerHTML = [Link];
</script>
</head>
</html>

[Link]() method
<!DOCTYPE html>
<title>[Link]()</title>
<p>The <code>[Link]()</code> function returns the value of the given number
rounded to the nearest integer.</p>
Rounding off 53.478
<p id="msg1"></p>
Rounding off 53.512
<p id="msg2"></p>
<script>
[Link]("msg1").innerHTML = [Link](53.478);
[Link]("msg2").innerHTML = [Link](53.512);
</script>
The [Link]()
The [Link]() function returns a floating-point, random number between 0 (inclusive)
and 1 (exclusive).

<!DOCTYPE html>
<html>
<head><title>[Link]()</title></head>
<body>
<p>The <code>[Link]()</code> function returns a floating-point, random number
between 0 (inclusive) and 1 (exclusive).</p>
<p id="msg1"></p>
Manipulating the random number
<p id="msg2"></p>
<script>
[Link]("msg1").innerHTML = [Link]();
[Link]("msg2").innerHTML = [Link]()*100;
</script>
</body>
</html>

<!DOCTYPE html>
<HTML>
<head><title>Manipulating [Link]()</title></head>
<body>
<p><code>[Link]()</code> returns a floating-point number
<p id="msg1"></p>
We can multiply [Link]() by 100 then use <code>[Link]()</code>
to return the largest integer less than or equal to the random number.
<p id="msg2"></p>
We can multiply [Link]() by 100 then use <code>[Link]()</code>
to return the smallest integer greater than or equal to the random number.<br>
This provides a more uniform distribution than using <code>[Link]()</code>.</p>
<p id="msg3"></p>
<script>
[Link]("msg1").innerHTML = [Link]();
[Link]("msg2").innerHTML = [Link]([Link]() * 100);
[Link]("msg3").innerHTML = [Link]([Link]() * 100);
</script>
</body>
</HTML>

You might also like