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

issubnormal宏


概要:
#include <math.h>
int issubnormal(real-floating x);

描述:

该宏是函数式宏(function-like macro),判断参数x是否为次规格化数(subnormal number)。

如果参数x的表示形式宽于real-floating,将转换成real-floating类型;然后再根据real-floating类型进行判断。


参数:
real-floating x

参数x应为实数浮点类型表达式,例如:float、double、long double类型表达式。


返回值:

如果参数x是次规格化数,该宏返回非0值。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
/*宏issubnormal范例*/

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

int main(void)
{
    #if __STDC_VERSION_MATH_H__ >= 202311L
        if(issubnormal(0.0))
            puts("0.0 is subnormal.");

        if(issubnormal(3.14))
            puts("3.14 is subnormal.");

        if(issubnormal(DBL_MIN/2.0))
            puts("DBL_MIN/2.0 is subnormal.");

        if(issubnormal(0.0/0.0))
            puts("0.0/0.0 is subnormal.");

        if(issubnormal(1.0/0.0))
            puts("1.0/0.0 is subnormal.");
    #else
        puts("The implementation may not support issubnormal.");
    #endif
    
    return 0;
}

输出:

The implementation may not support issubnormal.

表达式DBL_MIN/2.0值是次规格化数。


相关内容:
fpclassify 对参数按浮点类别进行分类的宏。
isfinite 判断参数是否为有限值的宏。
isinf 判断参数是否为无穷大的宏。
isnan 判断参数是否为非数值的宏。
issignaling 判断参数是否为信号非数值的宏。
isnormal 判断参数是否为规格化数的宏。
iszero 判断参数是否为0的宏。


主要参考资料:

1、ISO/IEC 9899:2024