#C 语言标准库函数 rootnd64
#include <math.h>
_Decimal64 rootnd64(_Decimal64 x, long long int n);
说明
求指定整数阶的主实根。负阶数对应正阶实根的倒数。
阶数为零或对负值求偶数阶根时发生定义域错误。零配负阶数可能发生极点错误。
自 C23 起提供。需要实现定义 __STDC_IEC_60559_DFP__ 并提供对应的十进制浮点接口。
参数
x- 被开方数。n- 非零整数根阶数。
返回值
- 返回 x 的 n 次实根。
#示例
使用 GCC 时,在链接命令末尾添加 -lm。
#include <math.h>
#include <stdio.h>
int main(void)
{
_Decimal64 computed = rootnd64(16.0dd, 4);
printf("%Lg\n", (long double)computed);
return !(computed == 2.0dd);
}
运行结果。
2
#相关接口
- 接口变体 rootn、rootnf、rootnl、rootnd32、rootnd128
- 类型通用分派 rootn(类型通用宏)
- 相关操作 cbrtd64、compoundnd64、pownd64、rsqrtd64、sqrtd64