#C 语言标准库函数 sqrtd64
#include <math.h>
_Decimal64 sqrtd64(_Decimal64 x);
说明
计算非负实数的主平方根。
输入小于零时发生定义域错误。
自 C23 起提供。需要实现定义 __STDC_IEC_60559_DFP__ 并提供对应的十进制浮点接口。
参数
x- 被开方数。
返回值
- 返回非负平方根。在 IEC 60559 实现中保留零的符号。
#示例
使用 GCC 时,在链接命令末尾添加 -lm。
#include <math.h>
#include <stdio.h>
int main(void)
{
_Decimal64 computed = sqrtd64(9.0dd);
printf("%Lg\n", (long double)computed);
return !(computed == 3.0dd);
}
运行结果。
3
#相关接口
- 接口变体 sqrt、sqrtf、sqrtl、sqrtd32、sqrtd128
- 类型通用分派 sqrt(类型通用宏)
- 相关操作 cbrtd64、d64sqrtd128、hypotd64、powd64、rootnd64、rsqrtd64