std::numeric_limits<T>::denorm_min
From cppreference.com
static T denorm_min() throw(); |
(C++11まで) | |
| static constexpr T denorm_min() noexcept; |
(C++11以降) | |
型Tの最小の正の非正規化数を返します。ただし、std::numeric_limits<T>::has_denorm != std::denorm_absent の場合、それ以外の場合は浮動小数点型ではstd::numeric_limits<T>::min()、その他のすべての型ではT() を返します。浮動小数点型でのみ意味があります。
[編集] 戻り値
T
|
std::numeric_limits<T>::denorm_min() |
| /* 非特殊化 */ | T() |
| bool | false |
| char | 0 |
| signed char | 0 |
| unsigned char | 0 |
| wchar_t | 0 |
| char8_t (C++20 以降) | 0 |
| char16_t (C++11 以降) | 0 |
| char32_t (C++11 以降) | 0 |
| short | 0 |
| unsigned short | 0 |
| int | 0 |
| unsigned int | 0 |
| long | 0 |
| unsigned long | 0 |
| long long (C++11 以降) | 0 |
| unsigned long long (C++11 以降) | 0 |
| float | FLT_TRUE_MIN (2-149 if std::numeric_limits<float>::is_iec559 true |
| double | DBL_TRUE_MIN (2-1074 if std::numeric_limits<double>::is_iec559 true |
| long double | LDBL_TRUE_MIN |
[編集] 例
denorm_min() の基となるビット構造をデモンストレーションし、値を表示します。
このコードを実行
#include <cassert> #include <cstdint> #include <cstring> #include <iostream> #include <limits> int main() { // the smallest subnormal value has sign bit = 0, exponent = 0 // and only the least significant bit of the fraction is 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
[編集] 関連項目
| [static] |
与えられた非浮動小数点数型の最小の有限値を返すか、与えられた浮動小数点数型の最小の正の正規化された値を返す (public static member function) |
| [static] |
浮動小数点数型で使用される非正規化のスタイルを識別する (public static member constant) |
| [static] (C++11) |
与えられた型の最小の有限値を返す。すなわち、符号付き型の場合は最も負の値、符号なし型の場合は 0 (public static member function) |