#C 语言标准库函数 roundevend32
#include <math.h>
_Decimal32 roundevend32(_Decimal32 x);
说明
将实数就近舍入且中点取偶取整。
舍入规则独立于当前浮点舍入方向。
自 C23 起提供。需要实现定义 __STDC_IEC_60559_DFP__ 并提供对应的十进制浮点接口。
参数
x- 参与运算的实浮点值。
返回值
- 返回舍入后的整数值。返回类型仍为浮点类型。
#示例
使用 GCC 时,在链接命令末尾添加 -lm。
#include <math.h>
#include <stdio.h>
int main(void)
{
_Decimal32 computed = roundevend32(-2.5df);
printf("%Lg\n", (long double)computed);
return !(computed == -2);
}
运行结果。
-2
#相关接口
- 接口变体 roundeven、roundevenf、roundevenl、roundevend64、roundevend128
- 类型通用分派 roundeven(类型通用宏)
- 相关操作 nearbyintd32、roundd32