C# Math - Cbrt() Method
The C# Cbrt() method returns the cube root of the given number. In special cases it returns the following:
- If the argument is NaN, then method returns NaN.
Syntax
public static float Cbrt (float arg);
Parameters
arg |
Specify a number. |
Return Value
Returns the cube root of the specified number.
Example:
In the example below, Cbrt() method is used to find out the cube root of the given number.
using System; class MyProgram { static void Main(string[] args) { Console.WriteLine("Math.Cbrt(64) = " + Math.Cbrt(64)); Console.WriteLine("Math.Cbrt(100) = " + Math.Cbrt(100)); Console.WriteLine("Math.Cbrt(-100) = " + Math.Cbrt(-100)); Console.WriteLine("Math.Cbrt(Double.NaN) = " + Math.Cbrt(Double.NaN)); Console.WriteLine("Math.Cbrt(Double.NegativeInfinity) = " + Math.Cbrt(Double.NegativeInfinity)); Console.WriteLine("Math.Cbrt(Double.PositiveInfinity) = " + Math.Cbrt(Double.PositiveInfinity)); } }
The output of the above code will be:
Math.Cbrt(64) = 4 Math.Cbrt(100) = 4.64158883361278 Math.Cbrt(-100) = -4.64158883361278 Math.Cbrt(Double.NaN) = NaN Math.Cbrt(Double.NegativeInfinity) = -Infinity Math.Cbrt(Double.PositiveInfinity) = Infinity
❮ C# Math Methods