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

HUGE_VAL_D128宏


概要:
#include <math.h>
#define HUGE_VAL_D128 value	//value值由实现定义。

描述:

该宏会扩展为_Decimal128类型的常量表达式,表示正无穷大。

只有实现定义了宏__STDC_IEC_60559_DFP__,并且用户代码在包含<math.h>头文件前定义了宏__STDC_WANT_IEC_60559_EXT__,该宏才存在。


范例:
1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
/*宏HUGE_VAL_D128范例*/

#define __STDC_WANT_IEC_60559_EXT__ 1

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

int main(void)
{
    #ifdef __STDC_IEC_60559_DFP__
        if(powd128(10.0dl, 1000.0dl) == HUGE_VAL_D128)
            puts("The result is HUGE_VAL_D128.");
        else
            puts("The result is finite.");
    #else
        puts("The implementation does not support decimal floating types.");
    #endif

    return 0;
}


输出:

The implementation does not support decimal floating types.


相关内容:
HUGE_VAL_D32 表示_Decimal32类型正无穷大的宏。
HUGE_VAL_D64 表示_Decimal64类型正无穷大的宏。


主要参考资料:

1、ISO/IEC 9899:2024