Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c#
cbrt
math
communitycreator

What is Math.Cbrt() in C#?

Arslan Bajwa

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.

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
communitycreator

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.

Keep Exploring