Calculates the cube root of a double precision floating-point value.
Include
<math.h>
Prototype
long double cbrtl(long double x);
Argument
x
Return Value
Returns the non-negative square root of x
.
Example
#include <math.h>
#include <stdio.h>
#include <errno.h>
int main(void)
{
double x, y;
errno = 0;
x = 0.0;
y = cbrtl(x);
if (errno)
perror("Error");
printf("The cube root of %Lf is %Lf\n", x, y);
errno = 0;
x = 9.5;
y = cbrtl(x);
if (errno)
perror("Error");
printf("The cube root of %Lf is %Lf\n", x, y);
errno = 0;
x = -25.0;
y = cbrtl(x);
if (errno)
perror("Error");
printf("The cube root of %Lf is %Lf\n", x, y);
}
Example Output
The cube root of 0.000000 is 0.000000
The cube root of 9.500000 is 2.117912
The cube root of -25.000000 is -2.924018