Namespaces
Variants

cbrt, cbrtf, cbrtl

From cppreference.net
< c ‎ | numeric ‎ | math
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99) (C99) (C99) (C23)
Maximum/minimum operations
Exponential functions
Power functions
cbrt
(C99)
(C23)
(C23)

Trigonometric and hyperbolic functions
Nearest integer floating-point
(C99) (C99) (C99)
(C23) (C23) (C23) (C23)
Floating-point manipulation
Narrowing operations
(C23)
(C23)
(C23)
(C23)
(C23)
(C23)
Quantum and quantum exponent
Decimal re-encoding functions
Total order and payload functions
Classification
Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Types
Macro constants
Special floating-point values
Arguments and return values
Error handling
Fast operation indicators
헤더 파일에 정의됨 <math.h>
float cbrtf ( float arg ) ;
(1) (C99부터)
double cbrt ( double arg ) ;
(2) (C99부터)
long double cbrtl ( long double arg ) ;
(3) (C99부터)
헤더 파일에 정의됨 <tgmath.h>
#define cbrt( arg )
(4) (C99부터)
1-3) arg 의 세제곱근을 계산합니다.
4) 타입-제네릭 매크로: arg long double 타입을 가지면 cbrtl 이 호출됩니다. 그렇지 않고 arg 가 정수 타입이나 double 타입을 가지면 cbrt 가 호출됩니다. 그 외의 경우에는 cbrtf 가 호출됩니다.

목차

매개변수

arg - 부동소수점 값

반환값

오류가 발생하지 않으면, arg 의 세제곱근( 3 arg )이 반환됩니다.

언더플로우로 인해 범위 오류가 발생하는 경우, 올바른 결과(반올림 후)가 반환됩니다.

오류 처리

오류는 math_errhandling 에 명시된 대로 보고됩니다.

구현이 IEEE 부동 소수점 연산(IEC 60559)을 지원하는 경우,

  • 인수가 ±0 또는 ±∞인 경우, 변경 없이 반환됩니다.
  • 인수가 NaN인 경우, NaN이 반환됩니다.

참고 사항

cbrt ( arg ) is not equivalent to pow ( arg, 1.0 / 3 ) because the rational number
1
3
is typically not equal to 1.0 / 3 and std::pow cannot raise a negative base to a fractional exponent. Moreover, cbrt ( arg ) usually gives more accurate results than pow ( arg, 1.0 / 3 ) (see 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));
}

가능한 출력:

Normal use:
cbrt(729)      = 9.000000
cbrt(-0.125)   = -0.500000
Special values:
cbrt(-0)       = -0.000000
cbrt(+inf)     = inf
Accuracy:
cbrt(343)      = 7.00000000000000000
pow(343,1.0/3) = 6.99999999999999911

참고문헌

  • C23 표준 (ISO/IEC 9899:2024):
  • 7.12.7.1 cbrt 함수들 (p: TBD)
  • 7.25 타입-제네릭 수학 <tgmath.h> (p: TBD)
  • F.10.4.1 cbrt 함수들 (p: TBD)
  • C17 표준 (ISO/IEC 9899:2018):
  • 7.12.7.1 cbrt 함수들 (p: 180-181)
  • 7.25 타입-제네릭 수학 <tgmath.h> (p: 272-273)
  • F.10.4.1 cbrt 함수들 (p: 381-)
  • C11 표준 (ISO/IEC 9899:2011):
  • 7.12.7.1 cbrt 함수들 (p: 247)
  • 7.25 타입-제네릭 수학 <tgmath.h> (p: 373-375)
  • F.10.4.1 cbrt 함수들 (p: 524)
  • C99 표준 (ISO/IEC 9899:1999):
  • 7.12.7.1 cbrt 함수들 (p: 228)
  • 7.22 타입-제네릭 수학 <tgmath.h> (p: 335-337)
  • F.9.4.1 cbrt 함수들 (p: 460)

참고 항목

(C99) (C99)
주어진 거듭제곱으로 올린 숫자를 계산합니다 ( x y )
(함수)
(C99) (C99)
제곱근을 계산합니다 ( x )
(함수)
(C99) (C99) (C99)
주어진 두 숫자의 제곱합의 제곱근을 계산합니다 ( x 2
+y 2
)
(함수)