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

FLT_MIN_EXP宏


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

描述:

宏FLT_MIN_EXP表示float类型浮点数的最小负指数emin,FLT_RADIX(FLT_MIN_EXP - 1)是float类型的规格化浮点数(normalized floating-point number)。


范例:
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 
/*宏FLT_MIN_EXP范例*/

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

int main(void)
{
  printf("FLT_MIN_EXP = %d\n", FLT_MIN_EXP);
  
  /*指数为FLT_MIN_EXP - 1。*/
  if(isnormal(powf(FLT_RADIX, FLT_MIN_EXP - 1)))
    puts("The result of powf(FLT_RADIX, FLT_MIN_EXP - 1) is a normal value.");
  else
    puts("The result of powf(FLT_RADIX, FLT_MIN_EXP - 1) is not a normal value.");
  
  /*指数为FLT_MIN_EXP - 2。*/
  if(isnormal(powf(FLT_RADIX, FLT_MIN_EXP - 2)))
    puts("The result of powf(FLT_RADIX, FLT_MIN_EXP - 2) is a normal value.");
  else
    puts("The result of powf(FLT_RADIX, FLT_MIN_EXP - 2) is not a normal value.");
  
  return 0;
}


输出:

FLT_MIN_EXP = -125

The result of powf(FLT_RADIX, FLT_MIN_EXP - 1) is a normal value.

The result of powf(FLT_RADIX, FLT_MIN_EXP - 2) is not a normal value.


相关内容:
DBL_MIN_EXP 表示double类型浮点数最小负指数的宏。
LDBL_MIN_EXP 表示long double类型浮点数最小负指数的宏。
DEC32_MIN_EXP 表示_Decimal32类型浮点数最小指数的宏。


主要参考资料:

1、ISO/IEC 9899:2024

2、ISO/IEC 9899:2018