Grokking Modern System Design Interview for Engineers & Managers
Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.
The Go programming language uses the Cbrt
function to find the cubic root of a number.
To use this function, you must import the math
package in your file and access the Cbrt
function within it using the .
notation (math.Cbrt
). Here, Cbrt
is the actual function, while math
is the Go package that stores the definition of this function.
The definition of the Cbrt
function inside the math
package is:
The Cbrt
function takes a single argument of type float64
. This is the number you will want to find the cube root of.
The Cbrt
function returns a single value of type float64. This value represents the cube root of the argument.
Below are two types of return values that are only used by the function under certain circumstances:
NAN: Not a number, or NAN, is returned in all cases where the input argument is an undefined numeric value.
+ Inf: This is returned if the input value is positive infinity or equivalent.
- Inf: This is returned if the input value is negative infinity or equivalent.
Below is a simple example where we find out the cube-root of a positive number:
package mainimport "fmt"import "math"func main() {var x float64 = math.Cbrt(125)fmt.Println(x)}
The following is a program that shows how the function will behave if it is given infinity as argument:
package mainimport "fmt"import "math"func main() {var x float64 = math.Cbrt(math.Inf(-1))fmt.Println("Cuberoot of negative infinity is: ", x)}
RELATED TAGS
CONTRIBUTOR
Grokking Modern System Design Interview for Engineers & Managers
Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.