Cbrt()
function is used to find the cube root of the given input (x
– parameter) in Go language. The standard math package of Go programming language has Cbrt()
function.
Syntax of Cbrt()
Function in Go Language
The syntax of
Note:
Special cases are:
Cbrt()
function in Go Language is:1 | func Cbrt(x float64) float64 |
Note:
float64
is a data type in Go language which has IEEE-754 64-bit floating-point numbers.Special cases are:
Cbrt(±0) = ±0
Cbrt(±Inf) = ±Inf
Cbrt(NaN) = NaN
Parameters of Cbrt()
Function in Go Language
x
– Where x
is any Valid float64
Input value. This parameter is required.
Error Handling
If the
If there is no argument (
x
parameter is not a number (numeric value) Cbrt()
function returns an error
.If there is no argument (
x
– input value) passes to the function, then the compiler will produce an error
.
Return Value of Cbrt()
Function in Go Language
Cbrt()
function will return the cube root of the given input(x
– parameter).
GoLang Cbrt()
Function Example 1
1 2 3 4 5 6 7 8 9 10 | package main import "fmt" import "math" func main() { var x float64 x = math.Cbrt(17) fmt.Println(x) } |
Output:
2.571281590658235
GoLang Cbrt()
Function Example 2
1 2 3 4 5 6 7 8 9 10 | package main import "fmt" import "math" func main() { var x float64 x = math.Cbrt(-3) fmt.Println(x) } |
Output:
-1.4422495703074083
GoLang Cbrt()
Function Example 3
1 2 3 4 5 6 7 8 9 10 | package main import "fmt" import "math" func main() { var x float64 x = math.Cbrt(0) fmt.Println(x) } |
Output:
0
Loading...