std::numeric_limits<T>:: has_denorm_loss
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Basic types | |||||||||||||||||||||
| Fixed width integer types (C++11) | |||||||||||||||||||||
| Fixed width floating-point types (C++23) | |||||||||||||||||||||
|
|||||||||||||||||||||
| Numeric limits | |||||||||||||||||||||
| C numeric limits interface | |||||||||||||||||||||
| Runtime type information | |||||||||||||||||||||
|
|||||||||||||||||||||
| Static constants | ||||
|
numeric_limits::has_denorm_loss
|
||||
|
(C++11)
|
||||
| Static member functions | ||||
|
(C++11)
|
||||
| Helper types | ||||
|
static
const
bool
has_denorm_loss
;
|
(C++11 前) | |
|
static
constexpr
bool
has_denorm_loss
;
|
(C++11 起)
(C++23 中弃用) |
|
对于所有浮点类型
T
,当检测到创建次正规数时精度损失被识别为非规范化损失而非不精确结果时(见下文),
std::
numeric_limits
<
T
>
::
has_denorm_loss
的值为
true
。
目录 |
标准特化
T
|
std:: numeric_limits < T > :: has_denorm_loss 的值 |
| /* non-specialized */ | false |
| bool | false |
| char | false |
| signed char | false |
| unsigned char | false |
| wchar_t | false |
| char8_t (自 C++20 起) | false |
| char16_t (自 C++11 起) | false |
| char32_t (自 C++11 起) | false |
| short | false |
| unsigned short | false |
| int | false |
| unsigned int | false |
| long | false |
| unsigned long | false |
| long long (自 C++11 起) | false |
| unsigned long long (自 C++11 起) | false |
| float | 由实现定义 |
| double | 由实现定义 |
| long double | 由实现定义 |
注释
符合标准的IEEE 754浮点实现必须检测与次正规数生成相关的精度损失(若发生),并可通过以下两种不同方式之一实现:
- 非规范化损失:交付结果与指数范围无限制情况下计算得出的结果不同。
- 不精确结果:交付结果与指数范围和精度均无限制情况下计算得出的结果不同。
不存在非规范化损失机制的实现(精度损失在舍入后检测,作为不精确结果),该选项已在IEEE Std 754的2008年修订版中被移除。
libstdc++、libc++、libCstd 和 stlport4 对所有浮点类型将此常量定义为 false 。Microsoft Visual Studio 对所有浮点类型将其定义为 true 。
与所有浮点运算一样,精度损失可能引发 FE_INEXACT 。
示例
|
本节内容不完整
原因:缺少示例 |
参见
|
[static]
|
标识在舍入前检测微小值的浮点类型
(公开静态成员常量) |
|
[static]
|
标识浮点类型使用的非规范化风格
(公开静态成员常量) |