<cmath> (math.h)

function
<cmath> <ctgmath>

cbrt

     double cbrt  (double x);
      float cbrtf (float x);
long double cbrtl (long double x);
     double cbrt (double x);
      float cbrt (float x);
long double cbrt (long double x);
     double cbrt (T x);           // additional overloads for integral types
Compute cubic root
Returns the cubic root of x.

Header <tgmath.h> provides a type-generic macro version of this function.
Additional overloads are provided in this header (<cmath>) for the integral types: These overloads effectively cast x to a double before calculations (defined for T being any integral type).

Parameters

x
Value whose cubic root is computed.

Return Value

Cubic root of x.

Example

1
2
3
4
5
6
7
8
9
10
11
12
/* cbrt example */
#include <stdio.h>      /* printf */
#include <math.h>       /* cbrt */

int main ()
{
  double param, result;
  param = 27.0;
  result = cbrt (param);
  printf ("cbrt (%f) = %f\n", param, result);
  return 0;
}


Output:

cbrt (27.000000) = 3.000000

See also