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