ln()

manviii_278 total contributions
Published Oct 18, 2023
Contribute to Docs
The ln()
method in Kotlin’s math
class is used to calculate the natural logarithm of a number.
Syntax
ln(n)
n
: The number of typeDouble
for which the logarithm is to be calculated.
The ln()
method returns a value of type Double
, the logarithm of n
to e. The following values represent special cases:
ln(NaN)
isNaN
ln(n)
isNaN
ifn < 0.0
ln(+Inf)
is+Inf
ln(0.0)
is-Inf
Example
This example shows how to use the ln()
method to calculate the natural logarithm of 6
:
import kotlin.math.*fun main(){println(ln(6.0))}
The output of this code will be:
1.791759469228055
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.