HTML and CSS Reference
Table 9.6 Math Object Methods (continued)
Tangent of Number in radians
Converts Number to string
* Returns the value of E x where E is Euler's constant and x is the argument passed to it. Euler's constant is
Square Root, Power of, and Pi. The Math object comes with a number of common
mathematical constants (all uppercase), such as PI and natural log values, as well as meth-
ods to find the square root of a number, the power of a number, and so on. Example 9.20
demonstrates how to use some of these properties; the output is shown in Figure 9.24.
<head><title>The Math Object</title></head>
<h2>Math object Methods--sqrt(),pow()<br />
Math object Property--PI
document.write("The square root of " +num+ " is ");
document.write( Math.sqrt(num) ,".<br />");
document.write("PI is ");
document.write( Math.PI );
document.write(".<br />"+num+" raised to the 3rd power is " );
document.write( Math.pow(num,3) + ".");
The number 16 will be manipulated by Math methods and constants.
The Math object's sqrt() method returns the square root of number 16, which is 4.
The Math object's PI constant produces the value of PI.
The Math object's pow() methods raises and returns number 16 to the 3rd power,
which is 4096 (see Figure 9.24).