Math Constants
This page is moving; this old copy is retained for archival purposes only.
Question: How do I handle mathematical constants in JavaScript?
Answer: In JavaScript, some mathematical constants are predefined as
properties of the Math.PI // pi = 3.14159265... Math.E // e = 2.71828182... Math.LOG2E // log of e base 2 Math.LOG10E // log of e base 10 Math.LN2 // log of 2 base e Math.LN10 // log of 10 base e Math.SQRT2 // square root of 2 Math.SQRT1_2 // square root of 1/2Thus, there is no need to remember the exact value of e or π. Just use Math.E or Math.PI !
See also: |
Copyright © 1999-2011, JavaScripter.net.