Skip to main content

log

Function log 

Source
pub fn log(x: number, base: option<number>) -> number
Expand description

Returns the logarithm of a number in a given base.

§Parameters

  • x: a positive number.
  • base: the logarithm base (default e).

§Return value

The logarithm of x in the given base, as a float. Without base, returns the natural logarithm of x.

§Examples

print(math.log(math.exp(1)))   --> 1.0
print(math.log(8, 2))          --> 3.0
print(math.log(100, 10))       --> 2.0

§See also

exp