#C 语言标准库函数 llroundd128
#include <math.h>
long long int llroundd128(_Decimal128 x);
说明
将实数就近舍入且中点远离零取整。
舍入规则独立于当前浮点舍入方向。结果无法表示(包括无穷或 NaN)时可能报告定义域或范围错误,返回值不能当作有效整数使用。
自 C23 起提供。需要实现定义 __STDC_IEC_60559_DFP__ 并提供对应的十进制浮点接口。
参数
x- 参与运算的实浮点值。
返回值
- 返回舍入后的整数值。返回类型为
long long int。
#示例
使用 GCC 时,在链接命令末尾添加 -lm。
#include <math.h>
#include <stdio.h>
int main(void)
{
long long int computed = llroundd128(-2.5dl);
printf("%lld\n", computed);
return !(computed == -3);
}
运行结果。
-3
#相关接口
- 接口变体 llround、llroundf、llroundl、llroundd32、llroundd64
- 类型通用分派 llround(类型通用宏)
- 相关操作 lroundd128、roundd128