spacer
Yehuda Shiran November 5, 1999
Mathematical Constants
Tips: November 1999

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

JavaScript's built-in 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:

PropertyDescription
Math.EReturns Euler's constant, the base of natural logarithms. The E property is approximately equal to 2.718.
Math.LN10Returns the natural logarithm of 10. The LN10 property is approximately equal to 2.302.
Math.LN2Returns the natural logarithm of 2. The LN2 property is approximately equal to 0.693.
Math.LOG10EReturns the base-10 logarithm of E, Euler's constant. The LOG10E property is approximately equal to 0.434.
Math.2EReturns the base-2 logarithm of E, Euler's constant. The LOG2E property is approximately equal to 1.442.
Math.PIReturns the ratio of the circumference of a circle to its diameter. The PI property is approximately equal to 3.14159.
Math.SQRT1_2Returns 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.SQRT2Returns 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;
}


People who read this tip also read these tips:

Look for similar tips by subject:


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Search Engine Optimization: Selecting and Embedding Keywords · Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
IBM DB2 10 for z/OS: Justifying the Upgrade · Living La Vida Colo: Choosing the Right Colocation Facility · FTC Concerns over Social Media Privacy Linger