Main Index : Reference :
[float] log([float,int] x)
x
is a numeric value. Logarithms are not defined for x
<= 0.
log()
returns the natural logarithm of x
. The natural logarithm is the inverse to the function exp()
. For more information on the use of logarithms, please refer to a math book.
// Outputs "log(x) = 0.693147".
var x = 2.0;
var a = log(x);
println("log(x) = ",a);
// One can use the natural logarithm to calculate the logarithm
// in any base using the simple formula below.
//
// Outputs "logn(2,x) = 5.0000".
logn(base,x)
{
return log(x)/log(base);
}
var x = 32.0;
var a = logn(2,x);
println("logn(2,x) = ",a);