HUGE_VALF, HUGE_VAL, HUGE_VALL
| Common mathematical functions | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Mathematical special functions (C++17) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Mathematical constants (C++20) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Basic linear algebra algorithms (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Data-parallel types (SIMD) (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Floating-point environment (C++11) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Complex numbers | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Numeric array (
valarray
)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Pseudo-random number generation | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Bit manipulation (C++20) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Saturation arithmetic (C++26) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Factor operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Interpolations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Generic numeric operations | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| C-style checked integer arithmetic | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Nearest integer floating point operations | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Floating point manipulation functions | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| Classification and comparison | |||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
| Types | |||||||||||||||||||||||||||||||||||||||||
| Macro constants | |||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
|
定义于头文件
<cmath>
|
||
|
#define HUGE_VALF /* 由实现定义 */
|
(C++11 起) | |
|
#define HUGE_VAL /* 由实现定义 */
|
||
|
#define HUGE_VALL /* 由实现定义 */
|
(C++11 起) | |
宏 HUGE_VALF 、 HUGE_VAL 和 HUGE_VALL 展开为正浮点常量表达式,这些表达式在发生溢出时与浮点函数及运算符返回的值相等(参见 math_errhandling )。
| 常量 | 说明 |
HUGE_VALF
|
展开为表示溢出的正 float 表达式 |
HUGE_VAL
|
展开为表示溢出的正 double 表达式,该值不一定能表示为 float |
HUGE_VALL
|
展开为表示溢出的正 long double 表达式,该值不一定能表示为 float 或 double |
在支持浮点数无穷大的实现中,这些宏始终分别展开为 float 、 double 和 long double 类型的正无穷大。
注释
在不支持浮点数无穷大的实现中,这些宏会展开为各自类型的最大有限数值。
C++98 增加了数学函数的 float 和 long double 重载版本。存在一个问题: float 重载无法通过返回 HUGE_VAL 来指示溢出,因为不能保证该宏的值可以用 float 类型表示。
LWG问题357 正是针对此问题提出。LWG发现C99存在相同问题( float 与 long double 重载同样在C99中添加),且C99通过引入新宏 HUGE_VALF 与 HUGE_VALL 来解决该问题。因此该问题被关闭,C++11采纳了C99的解决方案。
参见
|
(C++11)
|
求值为正无穷大或保证使
float
类型溢出的值
(宏常量) |
|
C 文档
关于
HUGE_VAL
|
|