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

DBL_MAX_10_EXP宏


概要:

#define DBL_MAX_10_EXP value //value值由实现定义。


描述:

DBL_MAX_10_EXP表示基数为10double类型浮点数的最大指数, l o g 10 ( ( 1 - b - p ) b e max ) 10DBL_MAX_10_EXPdouble类型可表示的有限浮点数范围内。

DBL_MAX_10_EXP最小值为37,具体值由实现定义。


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

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

int main(void)
{
  printf("DBL_MAX_10_EXP = %d\n", DBL_MAX_10_EXP);
  printf("DBL_MAX_10_EXP = %d\n", (int)floor(log10(DBL_MAX)));
  
  /*指数为DBL_MAX_10_EXP。*/
  if(isnormal(pow(10, DBL_MAX_10_EXP)))
    puts("The result of pow(10, DBL_MAX_10_EXP) is a normal value.");
  else
    puts("The result of pow(10, DBL_MAX_10_EXP) is not a normal value.");
  
  /*指数为DBL_MAX_10_EXP + 1。*/
  if(isnormal(pow(10, DBL_MAX_10_EXP + 1)))
    puts("The result of pow(10, DBL_MAX_10_EXP + 1) is a normal value.");
  else
    puts("The result of pow(10, DBL_MAX_10_EXP + 1) is not a normal value.");
  
  return 0;
}


输出:

DBL_MAX_10_EXP = 308

DBL_MAX_10_EXP = 308

The result of pow(10, DBL_MAX_10_EXP) is a normal value.

The result of pow(10, DBL_MAX_10_EXP + 1) is not a normal value.


相关内容:
FLT_MAX_10_EXP 表示基数为10float类型浮点数最大指数的宏。
LDBL_MAX_10_EXP 表示基数为10long double类型浮点数最大指数的宏。