November 5, 1999 - Mathematical Constants
November 5, 1999 Mathematical Constants Tips: November 1999
Yehuda Shiran, Ph.D.
|
Math
object provides various mathematics functionality and constants. It is a top-level, predefined JavaScript object, so it cannot be instantiated using the new
operator. The properties of this object are well known mathematical constants:
Property | Description |
Math.E | Returns Euler's constant, the base of natural logarithms. The E property is approximately equal to 2.718. |
Math.LN10 | Returns the natural logarithm of 10. The LN10 property is approximately equal to 2.302. |
Math.LN2 | Returns the natural logarithm of 2. The LN2 property is approximately equal to 0.693. |
Math.LOG10E | Returns the base-10 logarithm of E , Euler's constant. The LOG10E property is approximately equal to 0.434. |
Math.2E | Returns the base-2 logarithm of E , Euler's constant. The LOG2E property is approximately equal to 1.442. |
Math.PI | Returns the ratio of the circumference of a circle to its diameter. The PI property is approximately equal to 3.14159. |
Math.SQRT1_2 | Returns he square root of 0.5, or one divided by the square root of 2. The SQRT1_2 property is approximately equal to 0.707. |
Math.SQRT2 | Returns the square root of 2. The SQRT2 property is approximately equal to 1.414. |
The following function returns the area of a circle with a given radius:
function circle(r) {
return Math.PI * r * r;
}