std::numeric_limits<T>::denorm_min
来自cppreference.com
< cpp | types | numeric limits
| static T denorm_min() throw(); |
(C++11 前) | |
| static constexpr T denorm_min() noexcept; |
(C++11 起) | |
若 std::numeric_limits<T>::has_denorm != std::denorm_absent 则返回 T 类型的最小正非正规值,否则返回 std::numeric_limits<T>::min() 。仅对浮点类型有意义。
返回值
T
|
std::numeric_limits<T>::denorm_min() |
| /* non-specialized */ | T()
|
| bool | false |
| char | 0 |
| signed char | 0 |
| unsigned char | 0 |
| wchar_t | 0 |
| char8_t | 0 |
| char16_t | 0 |
| char32_t | 0 |
| short | 0 |
| unsigned short | 0 |
| int | 0 |
| unsigned int | 0 |
| long | 0 |
| unsigned long | 0 |
| long long | 0 |
| unsigned long long | 0 |
| float | 若 std::numeric_limits<float>::is_iec559 == true 则为 2-149 |
| double | 若 std::numeric_limits<float>::is_iec559 == true 则为 2-1074 |
| long double | /* 实现定义 */ |
示例
演示 denorm_min() 的底层位结构
运行此代码
#include <cstdint> #include <cstring> #include <limits> #include <cassert> int main() { // 最小非正规值拥有符号位 = 0 ,指数 = 0 // 且仅有尾数的最小有效数字位为 1 std::uint32_t denorm_bits = 0x0001; float denorm_float; std::memcpy(&denorm_float, &denorm_bits, sizeof(float)); assert(denorm_float == std::numeric_limits<float>::denorm_min()); std::cout << "float\tmin()\t\tdenorm_min()\n"; std::cout << "\t" << std::numeric_limits<float>::min() << '\t'; std::cout << std::numeric_limits<float>::denorm_min() << '\n'; std::cout << "double\tmin()\t\tdenorm_min()\n"; std::cout << "\t" << std::numeric_limits<double>::min() << '\t'; std::cout << std::numeric_limits<double>::denorm_min() << '\n'; }
输出:
float min() denorm_min() 1.17549e-38 1.4013e-45 double min() denorm_min() 2.22507e-308 4.94066e-324
参阅
| [静态] |
返回给定类型的最小有限值 (公开静态成员函数) |
| [静态] |
鉴别浮点类型所用的非正规风格 (公开静态成员常量) |
| [静态] (C++11) |
返回给定类型的最低有限值 (公开静态成员函数) |