C# Cbrt()
Anonymous contributor
Published Nov 15, 2025
Contribute to Docs
The Math.Cbrt() method in C# returns the cube root of a given number. It handles positive, negative, and special floating-point values such as NaN and infinities.
Syntax
Math.Cbrt(double x)
Parameters:
x(double): The number whose cube root is to be calculated.
Return value:
The method will return a value of type double unless the value passed is one of the following:
- If
xisNaN, the method will returnNaN. - If
xisPositiveInfinity, the method will returnPositiveInfinity. - If
xisNegativeInfinity, the method will returnNegativeInfinity. - If
xis negative, the method will return the real cube root (a negative number).
Example
In this example, different numeric values are passed to Math.Cbrt() to calculate their cube roots:
using System;namespace MyCubeRoot {public class Example {public static void Main(string[] args) {double a = Math.Cbrt(27);double b = Math.Cbrt(-8);double c = Math.Cbrt(1000);double d = Math.Cbrt(0.125);Console.WriteLine(a);Console.WriteLine(b);Console.WriteLine(c);Console.WriteLine(d);}}}
This example results in the following output:
3.0000000000000004-2100.49999999999999994
Codebyte Example
In this example, the cube root of 64 is calculated using Math.Cbrt() and printed to the console:
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C# on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn Microsoft's popular C# programming language, used to make websites, mobile apps, video games, VR, and more.
- Beginner Friendly.15 hours