约 1358 字

约 7 分钟

#C 语言标准库函数 powd32

#include <math.h>

_Decimal32 powd32(_Decimal32 x, _Decimal32 y);

说明

将底数提升到实数指数指定的幂。

有限负底数要求有限指数为整数值。零的负次幂可能报告极点或定义域错误。结果超出类型可表示的范围时可能报告范围错误。数学错误的报告方式由 math_errhandling 指示。

自 C23 起提供。需要实现定义 __STDC_IEC_60559_DFP__ 并提供对应的十进制浮点接口。

参数

  • x - 底数。
  • y - 指数。

返回值

  • 返回乘方运算的结果。

#示例

使用 GCC 时,在链接命令末尾添加 -lm。

#include <math.h>
#include <stdio.h>

int main(void)
{
    _Decimal32 computed = powd32(2.0df, 5.0df);
    printf("%Lg\n", (long double)computed);
    return !(computed == 32.0df);
}

运行结果。

32

#相关接口

#参考标准

更新: 2026/11/28

作者: planc

创建: 2026/11/28