JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
Next
 

Math.log() Function

Name

Math.log() Function---compute a natural logarithm

Availability

Navigator 2.0, Internet Explorer 3.0

Synopsis

Math.log(x)

Arguments

x

Any numeric value or expression greater than zero.

Returns

The natural logarithm of x.

Description

Math.log() computes logex, the natural logarithm of its argument. The argument must be greater than zero.

Usage

You can compute the base-10 and base-2 logarithms of a number with the following formulas:

log10x  =  log10(e*logex)

log2x  =  log2(e*logex)

These formulas translate into the following JavaScript functions:

function log10(x) { return Math.LOG10E * Math.log(x); }
function log2(x) { return  Math.LOG2E * Math.log(x); }

See Also

"Math", "Math.exp()", "Math.LOG2E", "Math.LOG10E"


Previous Home Next
Math.LN2 Book Index Math.LOG10E

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell
Hosted by uCoz