math.log
Defined in module
"math"from "math" import logReturns the natural logarithm of x
Parameters
x | number | the number to take the logarithm of |
Return value
The natural logarithm of x, as a float.
Notes
The result is always a float, even when x is an integer: type(log(1)) is "float".
log(0) does not throw. It returns negative infinity. A negative x does not throw either; it returns NaN. Both print differently between compilers and platforms, so do not print them from portable code.
Example
from "math" import log
println("log(1) =", log(1))
println("log(2) =", log(2))
// the result is a float even when x is an integer
println("type(log(1)) =", type(log(1)))Output:
log(1) = 0
log(2) = 0.693147
type(log(1)) = floatSee also
log10 | Returns the base-10 logarithm of x |
exp | Returns e raised to the power of x |
pow | Returns x raised to the power y |
| math | module index |