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

DEC32_EPSILON宏


概要:
#include <float.h>
#define DEC32_EPSILON 1E-6DF

描述:

如果实现支持十进制浮点类型(即实现定义了宏__STDC_IEC_60559_DFP__。),宏DEC32_EPSILON才会被定义。

该宏表示_Decimal32类型大于1的、最小可表示规格化十进制浮点值和1之间的差值。


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

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

int main(void)
{
    #ifdef __STDC_IEC_60559_DFP__
        #ifdef DEC32_EPSILON
            printf("DEC32_EPSILON = %HE\n", DEC32_EPSILON);
        #else
            puts("The implementation does not define macro DEC32_EPSILON.");
        #endif
    #else
        puts("The implementation does not support decimal floating types.");
    #endif

    return 0;
}


输出:

The implementation does not support decimal floating types.

(注:编译时实现还未支持十进制浮点类型。)


相关内容:
FLT_EPSILON 表示float类型大于1的、最小可表示规格化值和1之间差值的宏。
DEC64_EPSILON 表示_Decimal64类型大于1的、最小可表示规格化十进制浮点值和1之间差值的宏。
DEC128_EPSILON 表示_Decimal128类型大于1的、最小可表示规格化十进制浮点值和1之间差值的宏。


主要参考资料:

1、ISO/IEC 9899:2024