JavaScript Math Object


JavaScript Math Object


JavaScript Math Object

JavaScript Contains a Large Set of the Math Objects. Math Objects is used 

To Performs the mathematical Operations. List of the All The Math Objects 

is given under the Following Table.

Methods of the Math Objects

For the Following List , Suppose

Var number=6.8;

Sr.Method Function How We Use Math Methods
1.ceilReturn the Upper integer value of the decimal number var num_ceil=Math.ceil(number);
document.write(num_ceil);
2.floor Return the Lower integer value of the decimal number var num_floor=Math.floor(number);
document.write(num_floor);
3.max Return the Maximum Value Among the set of value var num_max=Math.max(23,56,78,12);
document.write(num_max);
4.min Return the Maximum Value Among the set of value var num_min=Math.min(23,56,78,12);
document.write(num_min);
5.random Return The random decimal value between 0-1 var num_ran=Math.random();
document.write(num_ran);
6.round Return the round up value of the number var num_rou=Math.round(number);
document.write(num_rou);
7.sqrt Return the Square Root Value of the Number var num_sqr=Math.sqrt(number);
document.write(num_sqr);

Example of the Math Methods



<html>
<head>
<title> Math Methods</title>
<script type="text/javascript">
function math_methods()
{
var number=6.8;
document.write("<h1> i-World-Tech </h1>");
var num_ceil=Math.ceil(number);
document.write("ceil value = " + num_ceil +"<br/>");
var num_floor=Math.floor(number);
document.write("floor value = " + num_floor + "<br/>");
var num_max=Math.max(23,56,78,12);
document.write("Maximum Value Amoung the Number is " + num_max + "<br/>");
var num_min=Math.min(23,56,78,12);
document.write("Minimum Value Amoung the Number is " + num_min + "<br/>");
var num_ran=Math.random();
document.write("Random Value = " + num_ran + "<br/>");
var num_rou=Math.round(number);
document.write("Round Value of the given number = " + num_rou + "<br/>");
var num_sqr=Math.sqrt(number);
document.write("Square Value of the Number is " + num_sqr + "<br/>");
}
</script>
</head>

<body>
<input type="button" value="Example of Math Methods" onclick="math_methods();">
</body>
</html>


Trigonometric Objects

For The Following List , Suppose

var angle=1;

var value=-5;

Sr. Methods Function Example
1.abs Return the mathematically Absolute Value of the Number var val_abs=Math.abs(value);
document.write(val_abs);
2.acosReturn The inversion of the cos value of the number var ang_acos=Math.acos(angle);
document.write(ang_acos);
3.asin Return The inversion of the sin value of the number var ang_asin=Math.asin(angle);
document.write(ang_asin);
4.atan Return The inversion of the Tan value of the number var ang_atan=Math.atan(angle);
document.write(ang_atan);
5.cos Return The cos value of the number var ang_cos=Math.cos(angle);
document.write(ang_cos);
6.log Return The Log value of the number var ang_log=Math.log(angle);
document.write(ang_log);
7.pow Return The base number to the power of exponent number var val_pow=Math.pow(2,4);
document.write(val_pow);
8.sin Return The sin value of the number var ang_sin=Math.sin(angle);
document.write(ang_sin);
9.tan Return The tan value of the number var ang_tan=Math.tan(angle);
document.write(ang_tan);

Example of The Trigonometric Objects


<html>
<head>
<title> Trigonometric Objects </title>
<script type="text/javascript">
function tri_obj()
{
var angle=1;
var value=-5;
document.write("<h1> i-World-Tech </h1>");
var val_abs=Math.abs(value);
document.write(" Absolute Value of the Number = " + val_abs + "<br/>");
var ang_acos=Math.acos(angle);
document.write("Inversion of the cos value is =" + ang_acos + "<br/>");
var ang_asin=Math.asin(angle);
document.write("Inversion of the sin value is =" + ang_asin + "<br/>");
var ang_atan=Math.atan(angle);
document.write("Inversion of the tan value is =" + ang_atan + "<br/>");
var ang_cos=Math.cos(angle);
document.write("Cos value is =" + ang_cos + "<br/>");
var ang_log=Math.log(angle);
document.write("log value is =" + ang_log + "<br/>");
var val_pow=Math.pow(2,4);
document.write("Power value is =" + val_pow + "<br/>");
var ang_sin=Math.sin(angle);
document.write("Sin value is =" + ang_sin + "<br/>");
var ang_tan=Math.tan(angle);
document.write("Tan value is =" + ang_tan + "<br/>");
}
</script>
</head>
<body>
<input type="button" value="Example of Trigonometric Objects " onclick="tri_obj();">
</body>
</html>




Constants Objects

Sr. Objects Function
1.E Return the Value of Euler’s Constant
2.LN2 Return the Value of Natural Logarithm of 2
3.LN10 Return the Value of Natural Logarithm of 10
4.LOG2E Return the Value of Base 2 Logarithm of E
5.PI Return the Value of Pie (3.14159265)
6.LOG10E Return the Value of Base 10 Logarithm of
7.SQRT2 Return the Value of Square Root of 2
8.SQRT1_2 Return the Value of Square Root of ½

Thank You To All My Reader


Comments