ln1p

expect fun ln1p(x: Double): Double(source)

Computes ln(x + 1).

This function can be implemented to produce more precise result for x near zero.

Special cases:

  • ln1p(NaN) is NaN

  • ln1p(x) is NaN where x < -1.0

  • ln1p(-1.0) is -Inf

  • ln1p(+Inf) is +Inf

Since Kotlin

1.2

See also

function

function

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // ln1p has better precision for arguments close to zero
println("ln1p(1e-20) > 0.0 is ${ln1p(1e-20) > 0.0}") // true
println(ln1p(1e-20))
// compared to adding 1.0 to a value and passing it to ln
println(ln(1e-20 + 1.0)) // 0.0

// Special cases
println(ln1p(Double.NaN)) // NaN
println(ln1p(-2.0)) // NaN
println(ln1p(-1.0)) // -Infinity
println(ln1p(Double.POSITIVE_INFINITY)) // Infinity 
   //sampleEnd
}

expect fun ln1p(x: Float): Float(source)

Computes ln(x + 1).

This function can be implemented to produce more precise result for x near zero.

Special cases:

  • ln1p(NaN) is NaN

  • ln1p(x) is NaN where x < -1.0

  • ln1p(-1.0) is -Inf

  • ln1p(+Inf) is +Inf

Since Kotlin

1.2

See also

function

function

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // ln1p has better precision for arguments close to zero
println("ln1p(1e-20f) > 0.0f is ${ln1p(1e-20f) > 0.0f}") // true
println(ln1p(1e-20f))
// compared to adding 1.0 to a value and passing it to ln
println(ln(1e-20f + 1.0f)) // 0.0

// Special cases
println(ln1p(Float.NaN)) // NaN
println(ln1p(-2.0f)) // NaN
println(ln1p(-1.0f)) // -Infinity
println(ln1p(Float.POSITIVE_INFINITY)) // Infinity 
   //sampleEnd
}
actual inline fun ln1p(x: Double): Double(source)

Computes ln(x + 1).

This function can be implemented to produce more precise result for x near zero.

Special cases:

  • ln1p(NaN) is NaN

  • ln1p(x) is NaN where x < -1.0

  • ln1p(-1.0) is -Inf

  • ln1p(+Inf) is +Inf

Since Kotlin

1.2

See also

function

function

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // ln1p has better precision for arguments close to zero
println("ln1p(1e-20) > 0.0 is ${ln1p(1e-20) > 0.0}") // true
println(ln1p(1e-20))
// compared to adding 1.0 to a value and passing it to ln
println(ln(1e-20 + 1.0)) // 0.0

// Special cases
println(ln1p(Double.NaN)) // NaN
println(ln1p(-2.0)) // NaN
println(ln1p(-1.0)) // -Infinity
println(ln1p(Double.POSITIVE_INFINITY)) // Infinity 
   //sampleEnd
}

actual inline fun ln1p(x: Float): Float(source)

Computes ln(x + 1).

This function can be implemented to produce more precise result for x near zero.

Special cases:

  • ln1p(NaN) is NaN

  • ln1p(x) is NaN where x < -1.0

  • ln1p(-1.0) is -Inf

  • ln1p(+Inf) is +Inf

Since Kotlin

1.2

See also

function

function

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // ln1p has better precision for arguments close to zero
println("ln1p(1e-20f) > 0.0f is ${ln1p(1e-20f) > 0.0f}") // true
println(ln1p(1e-20f))
// compared to adding 1.0 to a value and passing it to ln
println(ln(1e-20f + 1.0f)) // 0.0

// Special cases
println(ln1p(Float.NaN)) // NaN
println(ln1p(-2.0f)) // NaN
println(ln1p(-1.0f)) // -Infinity
println(ln1p(Float.POSITIVE_INFINITY)) // Infinity 
   //sampleEnd
}
actual inline fun ln1p(x: Double): Double(source)

Computes ln(x + 1).

This function can be implemented to produce more precise result for x near zero.

Special cases:

  • ln1p(NaN) is NaN

  • ln1p(x) is NaN where x < -1.0

  • ln1p(-1.0) is -Inf

  • ln1p(+Inf) is +Inf

Since Kotlin

1.2

See also

function

function

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // ln1p has better precision for arguments close to zero
println("ln1p(1e-20) > 0.0 is ${ln1p(1e-20) > 0.0}") // true
println(ln1p(1e-20))
// compared to adding 1.0 to a value and passing it to ln
println(ln(1e-20 + 1.0)) // 0.0

// Special cases
println(ln1p(Double.NaN)) // NaN
println(ln1p(-2.0)) // NaN
println(ln1p(-1.0)) // -Infinity
println(ln1p(Double.POSITIVE_INFINITY)) // Infinity 
   //sampleEnd
}

actual inline fun ln1p(x: Float): Float(source)

Computes ln(x + 1).

This function can be implemented to produce more precise result for x near zero.

Special cases:

  • ln1p(NaN) is NaN

  • ln1p(x) is NaN where x < -1.0

  • ln1p(-1.0) is -Inf

  • ln1p(+Inf) is +Inf

Since Kotlin

1.2

See also

function

function

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // ln1p has better precision for arguments close to zero
println("ln1p(1e-20f) > 0.0f is ${ln1p(1e-20f) > 0.0f}") // true
println(ln1p(1e-20f))
// compared to adding 1.0 to a value and passing it to ln
println(ln(1e-20f + 1.0f)) // 0.0

// Special cases
println(ln1p(Float.NaN)) // NaN
println(ln1p(-2.0f)) // NaN
println(ln1p(-1.0f)) // -Infinity
println(ln1p(Float.POSITIVE_INFINITY)) // Infinity 
   //sampleEnd
}
actual external fun ln1p(x: Double): Double(source)

Computes ln(x + 1).

This function can be implemented to produce more precise result for x near zero.

Special cases:

  • ln1p(NaN) is NaN

  • ln1p(x) is NaN where x < -1.0

  • ln1p(-1.0) is -Inf

  • ln1p(+Inf) is +Inf

Since Kotlin

1.3

See also

function

function

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // ln1p has better precision for arguments close to zero
println("ln1p(1e-20) > 0.0 is ${ln1p(1e-20) > 0.0}") // true
println(ln1p(1e-20))
// compared to adding 1.0 to a value and passing it to ln
println(ln(1e-20 + 1.0)) // 0.0

// Special cases
println(ln1p(Double.NaN)) // NaN
println(ln1p(-2.0)) // NaN
println(ln1p(-1.0)) // -Infinity
println(ln1p(Double.POSITIVE_INFINITY)) // Infinity 
   //sampleEnd
}

actual external fun ln1p(x: Float): Float(source)

Computes ln(x + 1).

This function can be implemented to produce more precise result for x near zero.

Special cases:

  • ln1p(NaN) is NaN

  • ln1p(x) is NaN where x < -1.0

  • ln1p(-1.0) is -Inf

  • ln1p(+Inf) is +Inf

Since Kotlin

1.3

See also

function

function

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // ln1p has better precision for arguments close to zero
println("ln1p(1e-20f) > 0.0f is ${ln1p(1e-20f) > 0.0f}") // true
println(ln1p(1e-20f))
// compared to adding 1.0 to a value and passing it to ln
println(ln(1e-20f + 1.0f)) // 0.0

// Special cases
println(ln1p(Float.NaN)) // NaN
println(ln1p(-2.0f)) // NaN
println(ln1p(-1.0f)) // -Infinity
println(ln1p(Float.POSITIVE_INFINITY)) // Infinity 
   //sampleEnd
}
actual fun ln1p(x: Double): Double(source)

Computes ln(x + 1).

This function can be implemented to produce more precise result for x near zero.

Special cases:

  • ln1p(NaN) is NaN

  • ln1p(x) is NaN where x < -1.0

  • ln1p(-1.0) is -Inf

  • ln1p(+Inf) is +Inf

Since Kotlin

1.8

See also

function

function

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // ln1p has better precision for arguments close to zero
println("ln1p(1e-20) > 0.0 is ${ln1p(1e-20) > 0.0}") // true
println(ln1p(1e-20))
// compared to adding 1.0 to a value and passing it to ln
println(ln(1e-20 + 1.0)) // 0.0

// Special cases
println(ln1p(Double.NaN)) // NaN
println(ln1p(-2.0)) // NaN
println(ln1p(-1.0)) // -Infinity
println(ln1p(Double.POSITIVE_INFINITY)) // Infinity 
   //sampleEnd
}

actual fun ln1p(x: Float): Float(source)

Computes ln(a + 1).

This function can be implemented to produce more precise result for x near zero.

Special cases:

  • ln1p(NaN) is NaN

  • ln1p(x) is NaN where x < -1.0

  • ln1p(-1.0) is -Inf

  • ln1p(+Inf) is +Inf

Since Kotlin

1.8

See also

function

function

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // ln1p has better precision for arguments close to zero
println("ln1p(1e-20f) > 0.0f is ${ln1p(1e-20f) > 0.0f}") // true
println(ln1p(1e-20f))
// compared to adding 1.0 to a value and passing it to ln
println(ln(1e-20f + 1.0f)) // 0.0

// Special cases
println(ln1p(Float.NaN)) // NaN
println(ln1p(-2.0f)) // NaN
println(ln1p(-1.0f)) // -Infinity
println(ln1p(Float.POSITIVE_INFINITY)) // Infinity 
   //sampleEnd
}
actual fun ln1p(x: Double): Double(source)

Computes ln(x + 1).

This function can be implemented to produce more precise result for x near zero.

Special cases:

  • ln1p(NaN) is NaN

  • ln1p(x) is NaN where x < -1.0

  • ln1p(-1.0) is -Inf

  • ln1p(+Inf) is +Inf

Since Kotlin

1.8

See also

function

function

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // ln1p has better precision for arguments close to zero
println("ln1p(1e-20) > 0.0 is ${ln1p(1e-20) > 0.0}") // true
println(ln1p(1e-20))
// compared to adding 1.0 to a value and passing it to ln
println(ln(1e-20 + 1.0)) // 0.0

// Special cases
println(ln1p(Double.NaN)) // NaN
println(ln1p(-2.0)) // NaN
println(ln1p(-1.0)) // -Infinity
println(ln1p(Double.POSITIVE_INFINITY)) // Infinity 
   //sampleEnd
}

actual fun ln1p(x: Float): Float(source)

Computes ln(a + 1).

This function can be implemented to produce more precise result for x near zero.

Special cases:

  • ln1p(NaN) is NaN

  • ln1p(x) is NaN where x < -1.0

  • ln1p(-1.0) is -Inf

  • ln1p(+Inf) is +Inf

Since Kotlin

1.8

See also

function

function

Samples

import kotlin.math.*
import kotlin.test.*

fun main() { 
   //sampleStart 
   // ln1p has better precision for arguments close to zero
println("ln1p(1e-20f) > 0.0f is ${ln1p(1e-20f) > 0.0f}") // true
println(ln1p(1e-20f))
// compared to adding 1.0 to a value and passing it to ln
println(ln(1e-20f + 1.0f)) // 0.0

// Special cases
println(ln1p(Float.NaN)) // NaN
println(ln1p(-2.0f)) // NaN
println(ln1p(-1.0f)) // -Infinity
println(ln1p(Float.POSITIVE_INFINITY)) // Infinity 
   //sampleEnd
}