What constants are available to help with math operations?

John Zukowski

The Math object includes properties for several different constants:

  • E - base of the natural logarithms, 2.71828...
  • LN10 - natural log of 10, 2.30258...
  • LN2 - natural log of 2, 0.69314...
  • LOG10E - base 10 log of E, 0.43429...
  • LOG2E - base 2 log of E, 1.44269...
  • PI - PI, 3.14159...
  • SQRT2 - Square root of 2, 1.41421...
  • SQRT1_2 - Square root of 1/2, 0.70710...
For instance, to display the value of PI, you could use the following:
<form>
<input type="button" value="PI" onClick="window.alert(Math.PI);">
</form>
You'll finds these documented at the following locations, among others:
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact