std::numeri...::denorm_min(3)
okay so this is std::numeri...::denorm_min(3) from the C++ Standard Libary manual β yes, Libary, we're keeping the typo, it's iconic π
β¨
π NAME π
std::numeric_limits::denorm_min β aka std::numeric_limits::denorm_min, bestie. That's the name, and we are not changing it, no cap.
β¨ Synopsis β¨
Two moods depending on your C++ era, fr fr:
static T denorm_min() throw(); (until C++11)
static constexpr T denorm_min() noexcept; (since C++11)
Here's the tea π«: this returns the minimum positive subnormal value of type T if std::numeric_limits<T>::has_denorm != std::denorm_absent. If that's not the case, it returns std::numeric_limits<T>::min() for floating-point types and T() for all other types. It's only meaningful for floating-point types, so don't come for the non-float girlies expecting subnormal magic ππ
π Return value π
Left side is T, right side is std::numeric_limits<T>::denorm_min() β here's the whole lineup, every single one π:
/* non-specialized */βT()boolβfalsecharβ0signed charβ0unsigned charβ0wchar_tβ0char8_t(since C++20) β0char16_t(since C++11) β0char32_t(since C++11) β0shortβ0unsigned shortβ0intβ0unsigned intβ0longβ0unsigned longβ0long long(since C++11) β0unsigned long long since (since C++11)β0floatβFLT_TRUE_MIN (\(\scriptsize 2^{-149}\)2-149 if std::numeric_limits<float>::is_iec559 is true)doubleβDBL_TRUE_MIN (\(\scriptsize 2^{-1074}\)2-1074 if std::numeric_limits<double>::is_iec559 is true)long doubleβLDBL_TRUE_MIN
π¦ Example π¦
This demo shows the underlying bit structure of denorm_min() and prints the values. Run this code, bestie:
#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';
}
π¬ Possible output π¬
float min() denorm_min()
1.17549e-38 1.4013e-45
double min() denorm_min()
2.22507e-308 4.94066e-324
πΈ See also πΈ
minβ returns the smallest finite value of the given type [static] (public static member function)has_denormβ identifies the denormalization style used by the floating-point type [static] (public static member constant)lowestβ returns the lowest finite value of the given type [static] (C++11) (public static member function)
That's the whole page, bestie π«Ά source: http://cppreference.com Β· date: 2024.06.10 Β· page: std::numeri...::denorm_min(3). Bye π
β¨
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms