当前位置: C语言 -- 标准库 -- <math.h> -- nextdownf

nextdownf函数


概要:
#include <math.h>
float nextdownf(float x);

描述:

该函数确定float类型的、小于参数x的下一个可表示值。

如果参数x是float类型中绝对值最小的正数,并且实现支持有符号0,则nextdownf(x)为+0;否则nextdownf(x)为0。

如果参数x为0,nextdownf(x)是float类型中绝对值最小的负数。

如果参数x是float类型中绝对值最大的负数(有限值或者无穷大。),nextdownf(x)等于参数x。


参数:
float x

参数为float类型的浮点数。


返回值:

函数返回float类型的、小于参数x的下一个可表示值。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
/*函数nextdownf范例*/

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

int main(void)
{
    #if __STDC_VERSION_MATH_H__ >= 202311L
        float x = 3.00f;
        printf("%.*f\n", (FLT_DECIMAL_DIG-1), nextdownf(x));
    #else
        puts("The implementation does not support nextdownf function.");
    #endif

    return 0;
}

输出:

The implementation does not support nextdownf function.


相关内容:
nextdown 确定double类型的小于参数的下一个可表示值的函数。
nextdownl 确定long double类型的小于参数的下一个可表示值的函数。
nextdownd32 确定_Decimal32类型的小于参数的下一个可表示值的函数。
nextdownd64 确定_Decimal64类型的小于参数的下一个可表示值的函数。
nextdownd128 确定_Decimal128类型的小于参数的下一个可表示值的函数。


主要参考资料:

1、ISO/IEC 9899:2024