<float.h>

本文详细介绍了标准头文件<float.h>中关于浮点数类型的宏定义,包括精度、最大最小值等关键属性,并解释了如何使用这些宏来确定不同环境中浮点数的表现。
#define DBL_DIG <integer rvalue >= 10>
#define DBL_EPSILON <double rvalue <= 10^(-9)>
#define DBL_MANT_DIG <integer rvalue>
#define DBL_MAX <double rvalue >= 10^37>
#define DBL_MAX_10_EXP <integer rvalue >= 37>
#define DBL_MAX_EXP <integer rvalue>
#define DBL_MIN <double rvalue <= 10^(-37)>
#define DBL_MIN_10_EXP <integer rvalue <= -37>
#define DBL_MIN_EXP <integer rvalue>

#define FLT_DIG <integer rvalue >= 6>
#define FLT_EPSILON <float rvalue <= 10^(-5)>
#define FLT_MANT_DIG <integer rvalue>
#define FLT_MAX <float rvalue >= 10^37>
#define FLT_MAX_10_EXP <integer rvalue >= 37>
#define FLT_MAX_EXP <integer rvalue>
#define FLT_MIN <float rvalue <= 10^(-37)>
#define FLT_MIN_10_EXP <integer rvalue <= -37>
#define FLT_MIN_EXP <integer rvalue>
#define FLT_RADIX <#if expression >= 2>
#define FLT_ROUNDS <integer rvalue>

#define LDBL_DIG <integer rvalue >= 10>
#define LDBL_EPSILON <long double rvalue <= 10^(-9)>
#define LDBL_MANT_DIG <integer rvalue>
#define LDBL_MAX <long double rvalue >= 10^37>
#define LDBL_MAX_10_EXP <integer rvalue >= 37>
#define LDBL_MAX_EXP <integer rvalue>
#define LDBL_MIN <long double rvalue <= 10^(-37)>
#define LDBL_MIN_10_EXP <integer rvalue <= -37>
#define LDBL_MIN_EXP <integer rvalue>

Include the standard header <float.h> to determine various properties of floating-point type representations. The standard header <float.h> is available even in a freestanding implementation.

You can test only the value of the macro FLT_RADIX in an if directive. (The macro expands to a #if expression.) All other macros defined in this header expand to expressions whose values can be determined only when the program executes. (These macros are rvalue expressions.) Some target environments can change the rounding and error-reporting properties of floating-point type representations while the program is running.

DBL_DIG

#define DBL_DIG <integer rvalue >= 10>

The macro yields the precision in decimal digits for type double.

DBL_EPSILON

#define DBL_EPSILON <double rvalue <= 10^(-9)>

The macro yields the smallest X of type double such that 1.0 + X != 1.0.

DBL_MANT_DIG

#define DBL_MANT_DIG <integer rvalue>

The macro yields the number of mantissa digits, base FLT_RADIX, for type double.

DBL_MAX

#define DBL_MAX <double rvalue >= 10^37>

The macro yields the largest finite representable value of type double.

DBL_MAX_10_EXP

#define DBL_MAX_10_EXP <integer rvalue >= 37>

The macro yields the maximum integer X, such that 10^X is a finite representable value of type double.

DBL_MAX_EXP

#define DBL_MAX_EXP <integer rvalue>

The macro yields the maximum integer X, such that FLT_RADIX^(X - 1) is a finite representable value of type double.

DBL_MIN

#define DBL_MIN <double rvalue <= 10^(-37)>

The macro yields the smallest normalized, finite representable value of type double.

DBL_MIN_10_EXP

#define DBL_MIN_10_EXP <integer rvalue <= -37>

The macro yields the minimum integer X such that 10^X is a normalized, finite representable value of type double.

DBL_MIN_EXP

#define DBL_MIN_EXP <integer rvalue>

The macro yields the minimum integer X such that FLT_RADIX^(X - 1) is a normalized, finite representable value of type double.

FLT_DIG

#define FLT_DIG <integer rvalue >= 6>

The macro yields the precision in decimal digits for type float.

FLT_EPSILON

#define FLT_EPSILON <float rvalue <= 10^(-5)>

The macro yields the smallest X of type float such that 1.0 + X != 1.0.

FLT_MANT_DIG

#define FLT_MANT_DIG <integer rvalue>

The macro yields the number of mantissa digits, base FLT_RADIX, for type float.

FLT_MAX

#define FLT_MAX <float rvalue >= 10^37>

The macro yields the largest finite representable value of type float.

FLT_MAX_10_EXP

#define FLT_MAX_10_EXP <integer rvalue >= 37>

The macro yields the maximum integer X, such that 10^X is a finite representable value of type float.

FLT_MAX_EXP

#define FLT_MAX_EXP <integer rvalue>

The macro yields the maximum integer X, such that FLT_RADIX^(X - 1) is a finite representable value of type float.

FLT_MIN

#define FLT_MIN <float rvalue <= 10^(-37)>

The macro yields the smallest normalized, finite representable value of type float.

FLT_MIN_10_EXP

#define FLT_MIN_10_EXP <integer rvalue <= -37>

The macro yields the minimum integer X, such that 10^X is a normalized, finite representable value of type float.

FLT_MIN_EXP

#define FLT_MIN_EXP <integer rvalue>

The macro yields the minimum integer X, such that FLT_RADIX^(X - 1) is a normalized, finite representable value of type float.

FLT_RADIX

#define FLT_RADIX <#if expression >= 2>

The macro yields the radix of all floating-point representations.

FLT_ROUNDS

#define FLT_ROUNDS <integer rvalue>

The macro yields a value that describes the current rounding mode for floating-point operations. Note that the target environment can change the rounding mode while the program executes. How it does so, however, is not specified. The values are:

  • -1 if the mode is indeterminate
  • 0 if rounding is toward zero
  • 1 if rounding is to nearest representable value
  • 2 if rounding is toward +infinity
  • 3 if rounding is toward -infinity

An implementation can define additional values for this macro.

LDBL_DIG

#define LDBL_DIG <integer rvalue >= 10>

The macro yields the precision in decimal digits for type long double.

LDBL_EPSILON

#define LDBL_EPSILON <long double rvalue <= 10^(-9)>

The macro yields the smallest X of type long double such that 1.0 + X != 1.0.

LDBL_MANT_DIG

#define LDBL_MANT_DIG <integer rvalue>

The macro yields the number of mantissa digits, base FLT_RADIX, for type long double.

LDBL_MAX

#define LDBL_MAX <long double rvalue >= 10^37>

The macro yields the largest finite representable value of type long double.

LDBL_MAX_10_EXP

#define LDBL_MAX_10_EXP <integer rvalue >= 37>

The macro yields the maximum integer X, such that 10^X is a finite representable value of type long double.

LDBL_MAX_EXP

#define LDBL_MAX_EXP <integer rvalue>

The macro yields the maximum integer X, such that FLT_RADIX^(X - 1) is a finite representable value of type long double.

LDBL_MIN

#define LDBL_MIN <long double rvalue <= 10^(-37)>

The macro yields the smallest normalized, finite representable value of type long double.

LDBL_MIN_10_EXP

#define LDBL_MIN_10_EXP <integer rvalue <= -37>

The macro yields the minimum integer X, such that 10^X is a normalized, finite representable value of type long double.

LDBL_MIN_EXP

#define LDBL_MIN_EXP <integer rvalue>

The macro yields the minimum integer X, such that FLT_RADIX^(X - 1) is a normalized, finite representable value of type long double.

转载于:https://www.cnblogs.com/wintergrass/archive/2011/05/18/2049667.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值