Ø abs()
· This abs() method returns the absolute value of a number. This means that the negative value is converted into positive value.
Syntax : Math.abs(x)
Parameter | Description |
X | Required.Must be a numeric value. |
Example
<html>
<head>
<script language="javascript">
document.write(Math.abs(-10)+"<br/>");
document.write(Math.abs(25.98));
</script>
</head>
</html>
Output
10
25.98
Ø ceil()
· The ceil() method returns the value of a number rounded UPWARED to the nearest integer.
Syntax : Math.ceil(x)
Parameter | Description |
X | Required.Must be a numeric value. |
Example
<html>
<head>
<script language="javascript">
document.write(Math.ceil(-10.56)+"<br/>");
document.write(Math.ceil(25.98));
</script>
</head>
</html>
Output
-10
26
Ø floor()
· The floor() method returns the value of a number rounded DOWNWAREDS to the nearest integer.
Syntax : Math.floor(x)
Parameter | Description |
X | Required.Must be a numeric value. |
Example
<html>
<head>
<script language="javascript">
document.write(Math.floor(-10.56)+"<br/>");
document.write(Math.floor(25.98));
</script>
</head>
</html>
Output
-11
25
Ø pow()
· This is used to find the power of the number which is specified.
Syntax : Math.pow(base , exponential)
Example
<html>
<head>
<script language="javascript">
document.write(Math.pow(2,3));
</script>
</head>
</html>
Output
8
Ø random()
· This function generates the random integer value each time the page is refreshed. The return type is integer.
Syntax : Math.random()
Example
<html>
<head>
<script language="javascript">
document.write(Math.random());
</script>
</head>
</html>
Output
0.35570713112842123
Ø round()
· This function will round the floating value. If the value contains the digits that is greater than 5 then the digit 1 will be carried forward to the digit before it.
Syntax : Math.round(float value)
Example
<html>
<head>
<script language="javascript">
document.write(Math.round(34.556));
</script>
</head>
</html>
Output
35
Ø min()
· This function will find the minimum value form the given two number specified.
Syntax : Math.min(integer value1,integer value2)
Example
<html>
<head>
<script language="javascript">
document.write(Math.min(34,2));
</script>
</head>
</html>
Output
2
Ø max()
· This function will find the maximum value form the given two number specified.
Syntax : Math.max(integer value1,integer value2)
Example
<html>
<head>
<script language="javascript">
document.write(Math.max(34,2));
</script>
</head>
</html>
Output
34
Posted By : Hemangi Zala
No comments:
Post a Comment