6.11.27 cbrtf Function
Calculates the real cube root of a single precision floating-point value.
Include
<math.h>
Prototype
float cbrtf(float x);
Argument
x
- a non-negative floating-point value
Return Value
Returns the real cube root of x
.
Example
See the notes at the beginning of this chapter or section for
information on using printf()
or scanf()
(and other functions reading and writing the stdin
or
stdout
streams) in the example code.
#include <math.h>
#include <stdio.h>
#include <errno.h>
int main(void)
{
float x, y;
errno = 0;
x = 0.0;
y = cbrtf(x);
if (errno)
perror("Error");
printf("The cube root of %f is %f\n", x, y);
errno = 0;
x = 9.5;
y = cbrtf(x);
if (errno)
perror("Error");
printf("The cube root of %f is %f\n", x, y);
errno = 0;
x = -25.0;
y = cbrtf(x);
if (errno)
perror("Error");
printf("The cube root of %f is %f\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