Trusted answers to developer questions

What is Math.Cbrt() in C#?

Get Started With Machine Learning

Learn the fundamentals of Machine Learning with this free course. Future-proof your career by adding ML skills to your toolkit — or prepare to land a job in AI or Data Science.

C# has a built-in Math class that provides useful mathematical functions and operations. The class has the Cbrt() function, which is used to compute the cube root of a specified number.

Syntax

public static double Cbrt (double value);

Parameters

  • value: This is of the Double type and represents the input value for which we have to find Cbrt(). Its range is all double numbers.

Return value

  • Double: This returns a Double number representing the cube root of the value.
  • NaN: This returns NaN type for NaN input in value.
  • PositiveInfinity: This returns an input of PositiveInfinity in value.
  • NegativeInfinity: This returns an input of NegativeInfinity in value.

Example

using System;
class Educative
{
static void Main()
{
Double result = Math.Cbrt(-27);
System.Console.WriteLine("Cbrt(-27) = "+ result);
Double result1 = Math.Cbrt(Double.PositiveInfinity);
System.Console.WriteLine("Cbrt(∞) = "+ result1);
Double result2 = Math.Cbrt(27);
System.Console.WriteLine("Cbrt(27) = "+ result2);
Double result3 = Math.Cbrt(0.008);
System.Console.WriteLine("Cbrt(0.008) = "+ result3);
}
}

Output

Cbrt(-27) = -3
Cbrt(∞) = Infinity
Cbrt(27) = 3
Cbrt(0.008) = 0.2

RELATED TAGS

c#
cbrt
math
Did you find this helpful?