Skip to content

Latest commit

 

History

History
97 lines (74 loc) · 2.52 KB

cbrt-cbrtf-cbrtl.md

File metadata and controls

97 lines (74 loc) · 2.52 KB
title description ms.date api_name api_location api_type topic_type f1_keywords helpviewer_keywords ms.assetid
cbrt, cbrtf, cbrtl
API reference for cbrt, cbrtf, and cbrtl; which calculate a cube root
9/1/2020
cbrt
cbrtf
cbrtl
_o_cbrt
_o_cbrtf
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-math-l1-1-0.dll
DLLExport
apiref
cbrtl
cbrt
cbrtf
cbrtl function
cbrtf function
cbrt function
ab51d916-3db2-4beb-b46a-28b4062cd33f

cbrt, cbrtf, cbrtl

Calculates the cube root.

Syntax

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
);
#define cbrt(X) // Requires C11 or higher

Parameters

x
Floating-point value

Return value

The cbrt functions return the cube-root of x.

Input SEH exception _matherr exception
± INF, QNaN, IND none none

Remarks

Because C++ allows overloading, you can call overloads of cbrt that take float or long double types. In a C program, unless you're using the <tgmath.h> macro to call this function, cbrt always takes and returns double.

If you use the <tgmath.h> cbrt() macro, the type of the argument determines which version of the function is selected. See Type-generic math for details.

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

Requirements

Function C header C++ header
cbrt, cbrtf, cbrtl <math.h> <cmath>
cbrt macro <tgmath.h>

For more compatibility information, see Compatibility.

Example

// 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

See also

Math and floating-point support
exp, expf, expl
log, logf, log10, log10f
pow, powf, powl