std::numeric_limits<T>::has_denorm_loss
来自cppreference.com
< cpp | types | numeric limits
| static const bool has_denorm_loss; |
(C++11 前) | |
| static constexpr bool has_denorm_loss; |
(C++11 起) | |
std::numeric_limits<T>::has_denorm_loss 的值对于所有检测在创建非正规数时的精度损失为非正规化损失,而非不准确结果(见后述)的浮点类型 T 为 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 | false |
| char16_t | false |
| char32_t | false |
| short | false |
| unsigned short | false |
| int | false |
| unsigned int | false |
| long | false |
| unsigned long | false |
| long long | false |
| unsigned long long | false |
| float | 实现定义 |
| double | 实现定义 |
| long double | 实现定义 |
注意
与标准一致的非正规数的 IEEE 754 浮点实现要求检测关联到创建这种数的精度损失,若它出现,而且可以以二种迥异的方式进行:
1) 非正规化损失:产生的结果异于假如指数范围无界的情况下计算出的结果。
2) 不准确结果:产生的结果异于假如指数范围和精度均无界的情况下计算出的结果。
不存在非正规化损失机制的实现(精度损失在舍入后检测为不准确结果),而此选项在 IEEE 标准 754 的 2008 修订版被移除。
libstdc++ 、 libc++ 、 libCstd 及 stlport4 为所有浮点类型定义此常量为 false 。 Microsoft Visual Studio 为所有浮点类型定义它为 true 。
同任何浮点计算,精度损失可能引发 FE_INEXACT
示例
| 本节未完成 原因:暂无示例 |
参阅
| [静态] |
鉴别检测舍入前是否非正规的浮点类型 (公开静态成员常量) |
| [静态] |
鉴别浮点类型所用的非正规风格 (公开静态成员常量) |