log
Computes the logarithm of the value x to the given base.
Special cases:
log(x, b)isNaNif eitherxorbareNaNlog(x, b)isNaNwhenx < 0orb <= 0orb == 1.0log(+Inf, +Inf)isNaNlog(+Inf, b)is+Infforb > 1and-Infforb < 1log(0.0, b)is-Infforb > 1and+Infforb < 1
See also logarithm functions for common fixed bases: ln, log10 and log2.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(log(64.0, 4.0)) // 3.0
println(log(100.0, 10.0)) // 2.0
// √4 = 2 -> log₄2 = ½
println(log(2.0, 4.0)) // 0.5
// Special cases
println(log(Double.NaN, 2.0)) // NaN
println(log(-1.0, 2.0)) // NaN
println(log(1.0, 1.0)) // NaN
println(log(Double.POSITIVE_INFINITY, 0.5)) // -Infinity
println(log(0.0, 0.5)) // Infinity
//sampleEnd
}Computes the logarithm of the value x to the given base.
Special cases:
log(x, b)isNaNif eitherxorbareNaNlog(x, b)isNaNwhenx < 0orb <= 0orb == 1.0log(+Inf, +Inf)isNaNlog(+Inf, b)is+Infforb > 1and-Infforb < 1log(0.0, b)is-Infforb > 1and+Infforb < 1
See also logarithm functions for common fixed bases: ln, log10 and log2.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(log(9.0f, 3.0f)) // 2.0
println(log(1000.0f, 10.0f)) // 3.0
// √4 = 2 -> log₄2 = ½
println(log(2.0f, 4.0f)) // 0.5
// Special cases
println(log(Float.NaN, 2.0f)) // NaN
println(log(-1.0f, 2.0f)) // NaN
println(log(1.0f, 1.0f)) // NaN
println(log(Float.POSITIVE_INFINITY, 0.5f)) // -Infinity
println(log(0.0f, 0.5f)) // Infinity
//sampleEnd
}Computes the logarithm of the value x to the given base.
Special cases:
log(x, b)isNaNif eitherxorbareNaNlog(x, b)isNaNwhenx < 0orb <= 0orb == 1.0log(+Inf, +Inf)isNaNlog(+Inf, b)is+Infforb > 1and-Infforb < 1log(0.0, b)is-Infforb > 1and+Infforb < 1
See also logarithm functions for common fixed bases: ln, log10 and log2.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(log(64.0, 4.0)) // 3.0
println(log(100.0, 10.0)) // 2.0
// √4 = 2 -> log₄2 = ½
println(log(2.0, 4.0)) // 0.5
// Special cases
println(log(Double.NaN, 2.0)) // NaN
println(log(-1.0, 2.0)) // NaN
println(log(1.0, 1.0)) // NaN
println(log(Double.POSITIVE_INFINITY, 0.5)) // -Infinity
println(log(0.0, 0.5)) // Infinity
//sampleEnd
}Computes the logarithm of the value x to the given base.
Special cases:
log(x, b)isNaNif eitherxorbareNaNlog(x, b)isNaNwhenx < 0orb <= 0orb == 1.0log(+Inf, +Inf)isNaNlog(+Inf, b)is+Infforb > 1and-Infforb < 1log(0.0, b)is-Infforb > 1and+Infforb < 1
See also logarithm functions for common fixed bases: ln, log10 and log2.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(log(9.0f, 3.0f)) // 2.0
println(log(1000.0f, 10.0f)) // 3.0
// √4 = 2 -> log₄2 = ½
println(log(2.0f, 4.0f)) // 0.5
// Special cases
println(log(Float.NaN, 2.0f)) // NaN
println(log(-1.0f, 2.0f)) // NaN
println(log(1.0f, 1.0f)) // NaN
println(log(Float.POSITIVE_INFINITY, 0.5f)) // -Infinity
println(log(0.0f, 0.5f)) // Infinity
//sampleEnd
}Computes the logarithm of the value x to the given base.
Special cases:
log(x, b)isNaNif eitherxorbareNaNlog(x, b)isNaNwhenx < 0orb <= 0orb == 1.0log(+Inf, +Inf)isNaNlog(+Inf, b)is+Infforb > 1and-Infforb < 1log(0.0, b)is-Infforb > 1and+Infforb < 1
See also logarithm functions for common fixed bases: ln, log10 and log2.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(log(64.0, 4.0)) // 3.0
println(log(100.0, 10.0)) // 2.0
// √4 = 2 -> log₄2 = ½
println(log(2.0, 4.0)) // 0.5
// Special cases
println(log(Double.NaN, 2.0)) // NaN
println(log(-1.0, 2.0)) // NaN
println(log(1.0, 1.0)) // NaN
println(log(Double.POSITIVE_INFINITY, 0.5)) // -Infinity
println(log(0.0, 0.5)) // Infinity
//sampleEnd
}Computes the logarithm of the value x to the given base.
Special cases:
log(x, b)isNaNif eitherxorbareNaNlog(x, b)isNaNwhenx < 0orb <= 0orb == 1.0log(+Inf, +Inf)isNaNlog(+Inf, b)is+Infforb > 1and-Infforb < 1log(0.0, b)is-Infforb > 1and+Infforb < 1
See also logarithm functions for common fixed bases: ln, log10 and log2.
Since Kotlin
1.2Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(log(9.0f, 3.0f)) // 2.0
println(log(1000.0f, 10.0f)) // 3.0
// √4 = 2 -> log₄2 = ½
println(log(2.0f, 4.0f)) // 0.5
// Special cases
println(log(Float.NaN, 2.0f)) // NaN
println(log(-1.0f, 2.0f)) // NaN
println(log(1.0f, 1.0f)) // NaN
println(log(Float.POSITIVE_INFINITY, 0.5f)) // -Infinity
println(log(0.0f, 0.5f)) // Infinity
//sampleEnd
}Computes the logarithm of the value x to the given base.
Special cases:
log(x, b)isNaNif eitherxorbareNaNlog(x, b)isNaNwhenx < 0orb <= 0orb == 1.0log(+Inf, +Inf)isNaNlog(+Inf, b)is+Infforb > 1and-Infforb < 1log(0.0, b)is-Infforb > 1and+Infforb < 1
See also logarithm functions for common fixed bases: ln, log10 and log2.
Since Kotlin
1.3Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(log(64.0, 4.0)) // 3.0
println(log(100.0, 10.0)) // 2.0
// √4 = 2 -> log₄2 = ½
println(log(2.0, 4.0)) // 0.5
// Special cases
println(log(Double.NaN, 2.0)) // NaN
println(log(-1.0, 2.0)) // NaN
println(log(1.0, 1.0)) // NaN
println(log(Double.POSITIVE_INFINITY, 0.5)) // -Infinity
println(log(0.0, 0.5)) // Infinity
//sampleEnd
}Computes the logarithm of the value x to the given base.
Special cases:
log(x, b)isNaNif eitherxorbareNaNlog(x, b)isNaNwhenx < 0orb <= 0orb == 1.0log(+Inf, +Inf)isNaNlog(+Inf, b)is+Infforb > 1and-Infforb < 1log(0.0, b)is-Infforb > 1and+Infforb < 1
See also logarithm functions for common fixed bases: ln, log10 and log2.
Since Kotlin
1.3Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(log(9.0f, 3.0f)) // 2.0
println(log(1000.0f, 10.0f)) // 3.0
// √4 = 2 -> log₄2 = ½
println(log(2.0f, 4.0f)) // 0.5
// Special cases
println(log(Float.NaN, 2.0f)) // NaN
println(log(-1.0f, 2.0f)) // NaN
println(log(1.0f, 1.0f)) // NaN
println(log(Float.POSITIVE_INFINITY, 0.5f)) // -Infinity
println(log(0.0f, 0.5f)) // Infinity
//sampleEnd
}Computes the logarithm of the value x to the given base.
Special cases:
log(x, b)isNaNif eitherxorbareNaNlog(x, b)isNaNwhenx < 0orb <= 0orb == 1.0log(+Inf, +Inf)isNaNlog(+Inf, b)is+Infforb > 1and-Infforb < 1log(0.0, b)is-Infforb > 1and+Infforb < 1
See also logarithm functions for common fixed bases: ln, log10 and log2.
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(log(64.0, 4.0)) // 3.0
println(log(100.0, 10.0)) // 2.0
// √4 = 2 -> log₄2 = ½
println(log(2.0, 4.0)) // 0.5
// Special cases
println(log(Double.NaN, 2.0)) // NaN
println(log(-1.0, 2.0)) // NaN
println(log(1.0, 1.0)) // NaN
println(log(Double.POSITIVE_INFINITY, 0.5)) // -Infinity
println(log(0.0, 0.5)) // Infinity
//sampleEnd
}Computes the logarithm of the value x to the given base.
Special cases:
log(x, b)isNaNif eitherxorbareNaNlog(x, b)isNaNwhenx < 0orb <= 0orb == 1.0log(+Inf, +Inf)isNaNlog(+Inf, b)is+Infforb > 1and-Infforb < 1log(0.0, b)is-Infforb > 1and+Infforb < 1
See also logarithm functions for common fixed bases: ln, log10 and log2.
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(log(9.0f, 3.0f)) // 2.0
println(log(1000.0f, 10.0f)) // 3.0
// √4 = 2 -> log₄2 = ½
println(log(2.0f, 4.0f)) // 0.5
// Special cases
println(log(Float.NaN, 2.0f)) // NaN
println(log(-1.0f, 2.0f)) // NaN
println(log(1.0f, 1.0f)) // NaN
println(log(Float.POSITIVE_INFINITY, 0.5f)) // -Infinity
println(log(0.0f, 0.5f)) // Infinity
//sampleEnd
}Computes the logarithm of the value x to the given base.
Special cases:
log(x, b)isNaNif eitherxorbareNaNlog(x, b)isNaNwhenx < 0orb <= 0orb == 1.0log(+Inf, +Inf)isNaNlog(+Inf, b)is+Infforb > 1and-Infforb < 1log(0.0, b)is-Infforb > 1and+Infforb < 1
See also logarithm functions for common fixed bases: ln, log10 and log2.
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(log(64.0, 4.0)) // 3.0
println(log(100.0, 10.0)) // 2.0
// √4 = 2 -> log₄2 = ½
println(log(2.0, 4.0)) // 0.5
// Special cases
println(log(Double.NaN, 2.0)) // NaN
println(log(-1.0, 2.0)) // NaN
println(log(1.0, 1.0)) // NaN
println(log(Double.POSITIVE_INFINITY, 0.5)) // -Infinity
println(log(0.0, 0.5)) // Infinity
//sampleEnd
}Computes the logarithm of the value x to the given base.
Special cases:
log(x, b)isNaNif eitherxorbareNaNlog(x, b)isNaNwhenx < 0orb <= 0orb == 1.0log(+Inf, +Inf)isNaNlog(+Inf, b)is+Infforb > 1and-Infforb < 1log(0.0, b)is-Infforb > 1and+Infforb < 1
See also logarithm functions for common fixed bases: ln, log10 and log2.
Since Kotlin
1.8Samples
import kotlin.math.*
import kotlin.test.*
fun main() {
//sampleStart
println(log(9.0f, 3.0f)) // 2.0
println(log(1000.0f, 10.0f)) // 3.0
// √4 = 2 -> log₄2 = ½
println(log(2.0f, 4.0f)) // 0.5
// Special cases
println(log(Float.NaN, 2.0f)) // NaN
println(log(-1.0f, 2.0f)) // NaN
println(log(1.0f, 1.0f)) // NaN
println(log(Float.POSITIVE_INFINITY, 0.5f)) // -Infinity
println(log(0.0f, 0.5f)) // Infinity
//sampleEnd
}