cbrt

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

Returns the cube root of x. For any x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.

Special cases:

  • If the argument is NaN, then the result is NaN.

  • If the argument is infinite, then the result is an infinity with the same sign as the argument.

  • If the argument is zero, then the result is a zero with the same sign as the argument.

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   println(cbrt(8.0)) // 2.0
println(cbrt(-8.0)) // -2.0

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

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

Returns the cube root of x. For any x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.

Special cases:

  • If the argument is NaN, then the result is NaN.

  • If the argument is infinite, then the result is an infinity with the same sign as the argument.

  • If the argument is zero, then the result is a zero with the same sign as the argument.

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   println(cbrt(8.0f)) // 2.0
println(cbrt(-8.0f)) // -2.0

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

Returns the cube root of x. For any x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.

Special cases:

  • If the argument is NaN, then the result is NaN.

  • If the argument is infinite, then the result is an infinity with the same sign as the argument.

  • If the argument is zero, then the result is a zero with the same sign as the argument.

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   println(cbrt(8.0)) // 2.0
println(cbrt(-8.0)) // -2.0

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

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

Returns the cube root of x. For any x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.

Special cases:

  • If the argument is NaN, then the result is NaN.

  • If the argument is infinite, then the result is an infinity with the same sign as the argument.

  • If the argument is zero, then the result is a zero with the same sign as the argument.

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   println(cbrt(8.0f)) // 2.0
println(cbrt(-8.0f)) // -2.0

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

Returns the cube root of x. For any x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.

Special cases:

  • If the argument is NaN, then the result is NaN.

  • If the argument is infinite, then the result is an infinity with the same sign as the argument.

  • If the argument is zero, then the result is a zero with the same sign as the argument.

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   println(cbrt(8.0)) // 2.0
println(cbrt(-8.0)) // -2.0

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

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

Returns the cube root of x. For any x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.

Special cases:

  • If the argument is NaN, then the result is NaN.

  • If the argument is infinite, then the result is an infinity with the same sign as the argument.

  • If the argument is zero, then the result is a zero with the same sign as the argument.

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   println(cbrt(8.0f)) // 2.0
println(cbrt(-8.0f)) // -2.0

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

Returns the cube root of x. For any x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.

Special cases:

  • If the argument is NaN, then the result is NaN.

  • If the argument is infinite, then the result is an infinity with the same sign as the argument.

  • If the argument is zero, then the result is a zero with the same sign as the argument.

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   println(cbrt(8.0)) // 2.0
println(cbrt(-8.0)) // -2.0

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

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

Returns the cube root of x. For any x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.

Special cases:

  • If the argument is NaN, then the result is NaN.

  • If the argument is infinite, then the result is an infinity with the same sign as the argument.

  • If the argument is zero, then the result is a zero with the same sign as the argument.

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   println(cbrt(8.0f)) // 2.0
println(cbrt(-8.0f)) // -2.0

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

Returns the cube root of x. For any x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.

Special cases:

  • If the argument is NaN, then the result is NaN.

  • If the argument is infinite, then the result is an infinity with the same sign as the argument.

  • If the argument is zero, then the result is a zero with the same sign as the argument.

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   println(cbrt(8.0)) // 2.0
println(cbrt(-8.0)) // -2.0

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

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

Returns the cube root of x. For any x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.

Special cases:

  • If the argument is NaN, then the result is NaN.

  • If the argument is infinite, then the result is an infinity with the same sign as the argument.

  • If the argument is zero, then the result is a zero with the same sign as the argument.

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   println(cbrt(8.0f)) // 2.0
println(cbrt(-8.0f)) // -2.0

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

Returns the cube root of x. For any x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.

Special cases:

  • If the argument is NaN, then the result is NaN.

  • If the argument is infinite, then the result is an infinity with the same sign as the argument.

  • If the argument is zero, then the result is a zero with the same sign as the argument.

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   println(cbrt(8.0)) // 2.0
println(cbrt(-8.0)) // -2.0

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

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

Returns the cube root of x. For any x, cbrt(-x) == -cbrt(x); that is, the cube root of a negative value is the negative of the cube root of that value's magnitude.

Special cases:

  • If the argument is NaN, then the result is NaN.

  • If the argument is infinite, then the result is an infinity with the same sign as the argument.

  • If the argument is zero, then the result is a zero with the same sign as the argument.

Since Kotlin

1.8

Samples

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

fun main() { 
   //sampleStart 
   println(cbrt(8.0f)) // 2.0
println(cbrt(-8.0f)) // -2.0

// special cases
println(cbrt(Float.NaN)) // NaN
println(cbrt(Float.POSITIVE_INFINITY)) // Infinity
println(cbrt(Float.NEGATIVE_INFINITY)) // -Infinity
println(cbrt(-0.0f)) // -0.0 
   //sampleEnd
}