#C 语言标准库函数 nexttowardf
#include <math.h>
float nexttowardf(float x, long double y);
说明
从 x 向精度可能更高的 y 移动一个可表示步长。
可在不自行估算浮点间隔的情况下确定邻点。间距随当前值的量级变化。
自 C99 起提供。
参数
x- 起始值。y- 使用 扩展实浮点类型long double指定方向。
返回值
- 返回输入类型的相邻值。两参数相等时返回转换到结果类型的 y。
#示例
使用 GCC 时,在链接命令末尾添加 -lm。
#include <math.h>
#include <stdio.h>
int main(void)
{
printf("%d\n", nexttowardf(1.0f, 2.0L) > 1);
return 0;
}
#相关接口
- 接口变体 nexttoward、nexttowardl、nexttowardd32、nexttowardd64、nexttowardd128
- 类型通用分派 nexttoward(类型通用宏)
- 相关操作 nextafterf、nextdownf、nextupf