May 2011
Intermediate to advanced
1096 pages
40h 54m
English
Math.log() — compute a natural logarithm
Math.log(x)
xAny numeric value or expression greater than zero.
The natural logarithm of
x.
Math.log() computes
log e
x, the natural logarithm of its argument. The
argument must be greater than zero.
You can compute the base-10 and base-2 logarithms of a number with these formulas:
log10x=log10e·logexlog2x=log2e·logex
These formulas translate into the following JavaScript functions:
functionlog10(x){returnMath.LOG10E*Math.log(x);}functionlog2(x){returnMath.LOG2E*Math.log(x);}
Read now
Unlock full access