Name

Math.log( ) Method — compute the natural logarithm of a number

Availability

Flash 5; may be used when exporting Flash 4 movies

Synopsis

Math.log(x)

Arguments

x

A positive integer.

Returns

The natural logarithm of x.

Description

The log( ) method calculates the natural logarithm (i.e., the base-e logarithm) of a number. See the following example to calculate the base-10 logarithm.

Example

trace (Math.log(Math.E));   // Displays: 1

// Compute the base-10 logarithm of a number
function log10 (x) {
  return (Math.log(x) / Math.log(10));
}

Get ActionScript: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.