cbrt, cbrtf, cbrtl

Header: <math.h>

1-3) Computes the cube root of arg.

# Declarations

float cbrtf( float arg );

(since C99)

double cbrt( double arg );

(since C99)

long double cbrtl( long double arg );

(since C99)

#define cbrt( arg )

(since C99)

# Parameters

# Return value

If no errors occur, the cube root of arg ((\small{\sqrt[3]{arg} })3√arg), is returned.

# Notes

cbrt(arg) pow(arg, 1.0/3) (\small{\frac1{3} }) 13 1.0/3 std::pow cbrt(arg) pow(arg, 1.0/3)

# Example

#include <float.h>
#include <math.h>
#include <stdio.h>
 
int main(void)
{
    printf("Normal use:\n"
           "cbrt(729)      = %f\n", cbrt(729));
    printf("cbrt(-0.125)   = %f\n", cbrt(-0.125));
    printf("Special values:\n"
           "cbrt(-0)       = %f\n", cbrt(-0.0));
    printf("cbrt(+inf)     = %f\n", cbrt(INFINITY));
    printf("Accuracy:\n"
           "cbrt(343)      = %.*f\n", DBL_DECIMAL_DIG, cbrt(343));
    printf("pow(343,1.0/3) = %.*f\n", DBL_DECIMAL_DIG, pow(343, 1.0/3));
}

# See also