Javascript: The Math Object

10. December 2009 11:33

Javascript: The Math Object

 

Javascript also includes a predefined object for math functions. There are methods for constants like PI and methods for other mathematical needs.

 

The predefined constants are:

PI – Which represents Pi, the value is 3.1416

E – Stands for Euler’s constant “e”, which has the value 2.718

LN2 – Stands for the natural log of 2, which is about 0.693.

LN10 – Is the natural log of 10, which is about 2.302

LOG10E – Is the base 10 log of e, valued at 0.434

SQRT1_2 – The square root of one half, valued at 0.707

SQRT2 – The square root of two, about 1.414

 

The methods of the Math object:

Method Format/Usage
Abs-- Absolute Value Math.abs(a number)
Acos—Arc Cosine (measured in radians) Math.acos(a number)
Asin—Arc Sine (measured in radians) Math.asin(a number)
Atan –Arc Tangent (measured in rads) Math.atan(a number)
Cos – Cosine Math.cos(a number in radians)
Sin –Sine Math.sin(a number in radians)
Tan –Tangent Math.tan(a number in radians)
Ceil—Ceiling Rounds number up to nearest integer. Math.ceil(a number)
Floor—Rounds to the lowest integer. Math.floor(a number)
Exp—Returns “e” to the power of a number. Math.exp(a number)
Log –Returns the natural logarithm of a number . Math.log(a number)
Pow –Returns the base number to given power. Math.pow(the base, the exponent)
Max—Returns the higher of two values. Math.max(number 1, number 2)
Min—Returns the lesser of two values. Math.min(number 1, number 2)
Round—Rounds to the closest integer. Math.round(a number)
Sqrt—Returns the square root of a number. Math.sqrt(a number)




Comments

12/23/2009 6:05:33 PM #

hk_webdesign

Thank you for sharing

hk_webdesign People's Republic of China |

2/25/2010 2:12:15 AM #

stock trading

If you are open to having a guest blog poster please  let me know. I can provide  unique content for your webstie, thanks.

stock trading United States |

2/25/2010 3:47:36 AM #

Daniel Millions

Yes, I have been searching for this all week better now than never!

Daniel Millions United States |

4/28/2010 1:02:09 AM #

Rapidshare

I\'m happy I found this blog, I couldnt discover any info on this subject matter prior to. I also run a site and if you want to ever serious in a little bit of guest writing for me if possible feel free to let me know, i\'m always look for people to check out my site. Please stop by and leave a comment sometime!

Rapidshare United States |

5/21/2010 9:36:40 AM #

free board games

I am pretty happy to uncover this great site. I'd like to say thank you regarding this brilliant read. If you possibly could add Delicious button to your web-site, it will help you to reach far more persons online. Many thanks

free board games United States |

5/27/2010 11:56:32 AM #

online board games

I have found your site from bing and it really is outstanding. Thank you very much for giving out this sort of an awesome article!!!

online board games United States |

7/19/2010 4:06:03 AM #

Mario Ruedas

Great post. I want to start working out more <a href="http://acaiberrytablets.com">acai max cleanse</a> gosh!

Mario Ruedas United States |

7/29/2010 5:18:11 PM #

ImHosted Review

Thank you for this article, It's fantastic to see another BlogEngine.NET user. Most users these days tend to use other systems like Wordpress, but I think BlogEngine is the best system to use.

ImHosted Review United States |

Comments are closed


About the author

 The creators of the Web Design Blog have been creating web designs for over 12 years

Page List