cbrt, cbrtf, cbrtl

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at cbrt, cbrtf, cbrtl.

Calculates the cube root.

double cbrt(  
   double x   
);  
float cbrt(  
   float x   
);  // C++ only  
long double cbrt(  
   long double x  
);  // C++ only  
float cbrtf(  
   float x   
);  
long double cbrtl(  
   long double x  
);  

Parameters

x
Floating-point value

The cbrt functions return the cube-root of x.

InputSEH Exception_matherr Exception
± ∞, QNAN, INDnonenone

Because C++ allows overloading, you can call overloads of cbrt that take float or long double types. In a C program, cbrt always takes and returns double.

FunctionC headerC++ header
cbrt, cbrtf, cbrtl<math.h><cmath>

For additional compatibility information, see Compatibility.

// crt_cbrt.c  
// Compile using: cl /W4 crt_cbrt.c  
// This program calculates a cube root.  
  
#include <math.h>  
#include <stdio.h>  
  
int main( void )  
{  
   double question = -64.64;  
   double answer;  
  
   answer = cbrt(question);  
   printf("The cube root of %.2f is %.6f\n", question, answer);  
}  

The cube root of -64.64 is -4.013289  

Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

Floating-Point Support
exp, expf
log, logf, log10, log10f
pow, powf, powl

Show: