1. Technology
Send to a Friend via Email

Math Method Reference

Related Resources

Tutorial

The Math object holds useful methods and constants to use in mathematical calculations. These methods and constants can be substituted in your javascript wherever numerical values are allowed. The Math object is pre-defined so does not need to be defined before use. The methods available with the Math object are:

  • Math.abs(number) absolute value
  • Math.acos(number) arc cosine (in radians)
  • Math.asin(number) arc sine (in radians)
  • Math.atan(number) arc tangent (in radians)
  • Math.cos(num_radians) cosine
  • Math.sin(num_radians) sine
  • Math.tan(num_radians) tangent
  • Math.ceil(number) smallest integer >= number
  • Math.floor(number) largest integer <= number
  • Math.exp(number) e to the power of number
  • Math.log(number) natural log of number
  • Math.pow(base,exponent) base to exponent power
  • Math.max(number,number) greater of the two numbers
  • Math.min(number,number) smaller of the two numbers
  • Math.round(number) rounds the number to the nearest integer
  • Math.sqrt(number) finds the square root of the number

The Math object also defines a number of useful constants (approximate values indicated).

  • Math.PI pi (3.14159...)
  • Math.E e (2.718...)
  • Math.LN2 natural log of 2 (0.693...)
  • Math.LN10() natural log of 10 (2.302...)
  • Math.LOG10E() base 10 log of e (0.434...)
  • Math.SQRT1_2() square root of 1/2 (0.707...)
  • Math.SQRT2 square root of 2 (1.414...)
See More About

©2014 About.com. All rights reserved.