#C 语言标准库函数 powrd128
#include <math.h>
_Decimal128 powrd128(_Decimal128 x, _Decimal128 y);
说明
按指数与自然对数定义实数幂。底数须非负。
负底数或两个实参均为零时发生定义域错误。零底数配有限负指数可能报告极点错误。
自 C23 起提供。需要实现定义 __STDC_IEC_60559_DFP__ 并提供对应的十进制浮点接口。
参数
x- 非负底数。y- 实数指数。
返回值
- 返回 x 的 y 次幂。
#示例
使用 GCC 时,在链接命令末尾添加 -lm。
#include <math.h>
#include <stdio.h>
int main(void)
{
_Decimal128 computed = powrd128(4.0dl, 0.5dl);
printf("%Lg\n", (long double)computed);
return !(computed == 2.0dl);
}
运行结果。
2