---
title: cbrt
description: "计算x的立方根。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengboostkithistory/2200/accel/kunpengaccel_kml_16_0238.html
sourcePath: /source/zh/kunpengboostkithistory/2200/accel/kunpengaccel_kml_16_0238.html
indexId: 36072978960dc6f9dc6b51e6680654790e9d06a1df0d5a9cba2be43f9613face74
---
# cbrt

计算x的立方根。

#### 接口定义

C interface：

float cbrtf(float x);

double cbrt(double x);

double cbrt_18(double x); // 仅在高精度版本提供

Fortran interface：

RES = CBRTF(X);

RES = CBRT(X);


#### 参数

| 参数名 | 类型 | 描述 | 输入/输出 |
| --- | --- | --- | --- |
| x | 在cbrtf中，x是单精度浮点类型。 在cbrt中，x是双精度浮点类型。 在cbrt\_18中，x是双精度浮点类型。 | 表示输入数据的浮点值。 | 输入 |


#### 返回值

- 输入x为±0，返回±0。
- 输入x为+∞，返回+∞。
- 输入x为nan，返回nan。


#### 依赖

C: "km.h"

Fortran: "km.f03"


#### 示例

C interface：
```
// typical usage
double x1 = 1.0, x2 = 2.0, x3 = 3.0, x4 = 4.0;
// special handing
double a = 0.0, b = INFINITY, c = -INFINITY, d = NAN;
// print result
printf("cbrt(1.0) = %.15f\n", cbrt(x1));
printf("cbrt(2.0) = %.15f\n", cbrt(x2));
printf("cbrt(3.0) = %.15f\n", cbrt(x3));
printf("cbrt(4.0) = %.15f\n", cbrt(x4));
printf("cbrt(0.0) = %.15f\n", cbrt(a));
printf("cbrt(INFINITY) = %.15f\n", cbrt(b));
printf("cbrt(-INFINITY) = %.15f\n", cbrt(c));
printf("cbrt(NAN) = %.15f\n", cbrt(d));
/*
*
*  cbrt(1.0) = 1.000000000000000
*  cbrt(2.0) = 1.259921049894873
*  cbrt(3.0) = 1.442249570307408
*  cbrt(4.0) = 1.587401051968200
*  cbrt(0.0) = 0.000000000000000
*  cbrt(INFINITY) = inf
*  cbrt(-INFINITY) = -inf
*  cbrt(NAN) = nan
* */
```


Fortran interface：

```
REAL(8) :: X = 3.0
PRINT*,  CBRT(X)
!
! OUTPUT
!     1.442249570307408
!
```
