.log()

abereFejiro995340965010 total contributions
Published Nov 13, 2023
Contribute to Docs
The .log()
function in Lua’s math library calculates the natural logarithmic value of a given number. The natural logarithm is to the base e
, where e
is Euler’s number, an irrational constant approximately equal to 2.71828
.
Syntax
math.log(number)
number
: The number for which the natural logarithm is calculated.
Example
In this example, math.log()
calculates the natural logarithmic value of 20
:
local num = 20local result = math.log(num)local output = string.format("The natural Logarithm of %.0f: %.4f", num, result)print(output)
The above example will result in the following output:
The natural Logarithm of 20: 2.9957
All contributors
- abereFejiro995340965010 total contributions
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.