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

nextdown函数


概要:
#include <math.h>
double nextdown(double x);

描述:

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

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

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

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


参数:
double x

参数为double类型的浮点数。


返回值:

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


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

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

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

    return 0;
}

输出:

The implementation does not support nextdown function.


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


主要参考资料:

1、ISO/IEC 9899:2024