cbrt()
Anonymous contributor
Anonymous contributor2 total contributions
Anonymous contributor
Published Oct 18, 2023
Contribute to Docs
The math.cbrt()
method returns the cube root of the given argument.
Syntax
cbrt(n)
n
refers to the number passed to the method of typeDouble
orFloat
.
Example
The following example uses cbrt()
to return the cube roots of -6.5
, 2
, and -340.8
:
// version 1.1.2import kotlin.math.cbrtfun main(args: Array<String>) {val x = -6.5val y = 2.0val z = -340.8println("The cube root of $x is ${cbrt(x)}")println("The cube root of $y is ${cbrt(y)}")println("The cube root of $z is ${cbrt(z)}")}
This produces the following output:
The cube root of -6.5 is -1.862518585537463The cube root of 2.0 is 1.2599210498948732The cube root of -340.8 is -6.928203230275508
All contributors
- Anonymous contributorAnonymous contributor2 total contributions
- Anonymous contributor
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.