约 1335 字

约 7 分钟

#C 语言标准库函数 nexttowardd32

#include <math.h>

_Decimal32 nexttowardd32(_Decimal32 x, _Decimal128 y);

说明

从 x 向精度可能更高的 y 移动一个可表示步长。

可在不自行估算浮点间隔的情况下确定邻点。间距随当前值的量级变化。

自 C23 起提供。需要实现定义 __STDC_IEC_60559_DFP__ 并提供对应的十进制浮点接口。

参数

  • x - 起始值。
  • y - 使用 十进制最高精度类型 _Decimal128 指定方向。

返回值

  • 返回输入类型的相邻值。两参数相等时返回转换到结果类型的 y。

#示例

使用 GCC 时,在链接命令末尾添加 -lm。

#include <math.h>
#include <stdio.h>

int main(void)
{
    printf("%d\n", nexttowardd32(1.0df, 2.0dl) > 1);
    return 0;
}

#相关接口

#参考标准

更新: 2026/11/28

作者: planc

创建: 2026/11/28