exp

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

Computes Euler's number e raised to the power of the value x.

Special cases:

  • exp(NaN) is NaN

  • exp(+Inf) is +Inf

  • exp(-Inf) is 0.0

Since Kotlin

1.2

Samples

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

fun main() { 
   //sampleStart 
   fun Double.firstFiveDigits(): String = toString().substring(0, 7)

println(exp(1.0).firstFiveDigits()) // 2.71828
println(exp(2.0).firstFiveDigits()) // 7.38905
println(exp(-1.0).firstFiveDigits()) // 0.36787

// special cases
println(exp(Double.NaN)) // NaN
println(exp(Double.POSITIVE_INFINITY)) // Infinity
println(exp(Double.NEGATIVE_INFINITY)) // 0.0 
   //sampleEnd
}

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

Computes Euler's number e raised to the power of the value x.

Special cases:

  • exp(NaN) is NaN

  • exp(+Inf) is +Inf

  • exp(-Inf) is 0.0

Since Kotlin

1.2

Samples

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

fun main() { 
   //sampleStart 
   fun Float.firstFiveDigits(): String = toString().substring(0, 7)

println(exp(1.0f).firstFiveDigits()) // 2.71828
println(exp(2.0f).firstFiveDigits()) // 7.38905
println(exp(-1.0f).firstFiveDigits()) // 0.36787

// special cases
println(exp(Float.NaN)) // NaN
println(exp(Float.POSITIVE_INFINITY)) // Infinity
println(exp(Float.NEGATIVE_INFINITY)) // 0.0 
   //sampleEnd
}
actual inline fun exp(x: Double): Double(source)

Computes Euler's number e raised to the power of the value x.

Special cases:

  • exp(NaN) is NaN

  • exp(+Inf) is +Inf

  • exp(-Inf) is 0.0

Since Kotlin

1.2

Samples

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

fun main() { 
   //sampleStart 
   fun Double.firstFiveDigits(): String = toString().substring(0, 7)

println(exp(1.0).firstFiveDigits()) // 2.71828
println(exp(2.0).firstFiveDigits()) // 7.38905
println(exp(-1.0).firstFiveDigits()) // 0.36787

// special cases
println(exp(Double.NaN)) // NaN
println(exp(Double.POSITIVE_INFINITY)) // Infinity
println(exp(Double.NEGATIVE_INFINITY)) // 0.0 
   //sampleEnd
}

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

Computes Euler's number e raised to the power of the value x.

Special cases:

  • exp(NaN) is NaN

  • exp(+Inf) is +Inf

  • exp(-Inf) is 0.0

Since Kotlin

1.2

Samples

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

fun main() { 
   //sampleStart 
   fun Float.firstFiveDigits(): String = toString().substring(0, 7)

println(exp(1.0f).firstFiveDigits()) // 2.71828
println(exp(2.0f).firstFiveDigits()) // 7.38905
println(exp(-1.0f).firstFiveDigits()) // 0.36787

// special cases
println(exp(Float.NaN)) // NaN
println(exp(Float.POSITIVE_INFINITY)) // Infinity
println(exp(Float.NEGATIVE_INFINITY)) // 0.0 
   //sampleEnd
}
actual inline fun exp(x: Double): Double(source)

Computes Euler's number e raised to the power of the value x.

Special cases:

  • exp(NaN) is NaN

  • exp(+Inf) is +Inf

  • exp(-Inf) is 0.0

Since Kotlin

1.2

Samples

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

fun main() { 
   //sampleStart 
   fun Double.firstFiveDigits(): String = toString().substring(0, 7)

println(exp(1.0).firstFiveDigits()) // 2.71828
println(exp(2.0).firstFiveDigits()) // 7.38905
println(exp(-1.0).firstFiveDigits()) // 0.36787

// special cases
println(exp(Double.NaN)) // NaN
println(exp(Double.POSITIVE_INFINITY)) // Infinity
println(exp(Double.NEGATIVE_INFINITY)) // 0.0 
   //sampleEnd
}

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

Computes Euler's number e raised to the power of the value x.

Special cases:

  • exp(NaN) is NaN

  • exp(+Inf) is +Inf

  • exp(-Inf) is 0.0

Since Kotlin

1.2

Samples

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

fun main() { 
   //sampleStart 
   fun Float.firstFiveDigits(): String = toString().substring(0, 7)

println(exp(1.0f).firstFiveDigits()) // 2.71828
println(exp(2.0f).firstFiveDigits()) // 7.38905
println(exp(-1.0f).firstFiveDigits()) // 0.36787

// special cases
println(exp(Float.NaN)) // NaN
println(exp(Float.POSITIVE_INFINITY)) // Infinity
println(exp(Float.NEGATIVE_INFINITY)) // 0.0 
   //sampleEnd
}
actual external fun exp(x: Double): Double(source)

Computes Euler's number e raised to the power of the value x.

Special cases:

  • exp(NaN) is NaN

  • exp(+Inf) is +Inf

  • exp(-Inf) is 0.0

Since Kotlin

1.3

Samples

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

fun main() { 
   //sampleStart 
   fun Double.firstFiveDigits(): String = toString().substring(0, 7)

println(exp(1.0).firstFiveDigits()) // 2.71828
println(exp(2.0).firstFiveDigits()) // 7.38905
println(exp(-1.0).firstFiveDigits()) // 0.36787

// special cases
println(exp(Double.NaN)) // NaN
println(exp(Double.POSITIVE_INFINITY)) // Infinity
println(exp(Double.NEGATIVE_INFINITY)) // 0.0 
   //sampleEnd
}

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

Computes Euler's number e raised to the power of the value x.

Special cases:

  • exp(NaN) is NaN

  • exp(+Inf) is +Inf

  • exp(-Inf) is 0.0

Since Kotlin

1.3

Samples

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

fun main() { 
   //sampleStart 
   fun Float.firstFiveDigits(): String = toString().substring(0, 7)

println(exp(1.0f).firstFiveDigits()) // 2.71828
println(exp(2.0f).firstFiveDigits()) // 7.38905
println(exp(-1.0f).firstFiveDigits()) // 0.36787

// special cases
println(exp(Float.NaN)) // NaN
println(exp(Float.POSITIVE_INFINITY)) // Infinity
println(exp(Float.NEGATIVE_INFINITY)) // 0.0 
   //sampleEnd
}
actual fun exp(x: Double): Double(source)

Computes Euler's number e raised to the power of the value x.

Special cases:

  • exp(NaN) is NaN

  • exp(+Inf) is +Inf

  • exp(-Inf) is 0.0

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   fun Double.firstFiveDigits(): String = toString().substring(0, 7)

println(exp(1.0).firstFiveDigits()) // 2.71828
println(exp(2.0).firstFiveDigits()) // 7.38905
println(exp(-1.0).firstFiveDigits()) // 0.36787

// special cases
println(exp(Double.NaN)) // NaN
println(exp(Double.POSITIVE_INFINITY)) // Infinity
println(exp(Double.NEGATIVE_INFINITY)) // 0.0 
   //sampleEnd
}

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

Computes Euler's number e raised to the power of the value x.

Special cases:

  • exp(NaN) is NaN

  • exp(+Inf) is +Inf

  • exp(-Inf) is 0.0

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   fun Float.firstFiveDigits(): String = toString().substring(0, 7)

println(exp(1.0f).firstFiveDigits()) // 2.71828
println(exp(2.0f).firstFiveDigits()) // 7.38905
println(exp(-1.0f).firstFiveDigits()) // 0.36787

// special cases
println(exp(Float.NaN)) // NaN
println(exp(Float.POSITIVE_INFINITY)) // Infinity
println(exp(Float.NEGATIVE_INFINITY)) // 0.0 
   //sampleEnd
}
actual fun exp(x: Double): Double(source)

Computes Euler's number e raised to the power of the value x.

Special cases:

  • exp(NaN) is NaN

  • exp(+Inf) is +Inf

  • exp(-Inf) is 0.0

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   fun Double.firstFiveDigits(): String = toString().substring(0, 7)

println(exp(1.0).firstFiveDigits()) // 2.71828
println(exp(2.0).firstFiveDigits()) // 7.38905
println(exp(-1.0).firstFiveDigits()) // 0.36787

// special cases
println(exp(Double.NaN)) // NaN
println(exp(Double.POSITIVE_INFINITY)) // Infinity
println(exp(Double.NEGATIVE_INFINITY)) // 0.0 
   //sampleEnd
}

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

Computes Euler's number e raised to the power of the value x.

Special cases:

  • exp(NaN) is NaN

  • exp(+Inf) is +Inf

  • exp(-Inf) is 0.0

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   fun Float.firstFiveDigits(): String = toString().substring(0, 7)

println(exp(1.0f).firstFiveDigits()) // 2.71828
println(exp(2.0f).firstFiveDigits()) // 7.38905
println(exp(-1.0f).firstFiveDigits()) // 0.36787

// special cases
println(exp(Float.NaN)) // NaN
println(exp(Float.POSITIVE_INFINITY)) // Infinity
println(exp(Float.NEGATIVE_INFINITY)) // 0.0 
   //sampleEnd
}