#C 语言标准库函数 powf
#include <math.h>
float powf(float x, float y);
说明
将底数提升到实数指数指定的幂。
有限负底数要求有限指数为整数值。零的负次幂可能报告极点或定义域错误。结果超出类型可表示的范围时可能报告范围错误。数学错误的报告方式由 math_errhandling 指示。
自 C99 起提供。
参数
x- 底数。y- 指数。
返回值
- 返回乘方运算的结果。
#示例
使用 GCC 时,在链接命令末尾添加 -lm。
#include <math.h>
#include <stdio.h>
int main(void)
{
float computed = powf(2.0f, 5.0f);
printf("%Lg\n", (long double)computed);
return !(computed == 32.0);
}
运行结果。
32