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

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

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:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint