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