std::numeri...mits::lowest(3)
π
std::numeri...mits::lowest(3) π
okay bestie, welcome to the C++ Standard Libary manual page for std::numeric_limits::lowest, section (3) energy. This one is all about the lowest finite value a numeric type can hold, and it is so useful. No cap. β¨
πΈ NAME πΈ
std::numeric_limits::lowest β std::numeric_limits::lowest (yes, she said what she said π
)
β¨ Synopsis β¨
static constexpr T lowest() noexcept; (since C++11)
So this returns the lowest finite value representable by the numeric type T β that is, a finite value x such that there is no other finite value y where y < x. For floating-point types, this is different from std::numeric_limits<T>::min(). Itβs only meaningful for bounded types. π«Ά
π Return value π
Left side is T; right side is std::numeric_limits<T>::lowest():
/* non-specialized */βT()boolβfalsecharβCHAR_MINsigned charβSCHAR_MINunsigned charβ0wchar_tβWCHAR_MINchar8_t(since C++20) β0char16_tβ0char32_tβ0shortβSHRT_MINunsigned shortβ0intβINT_MINunsigned intβ0longβLONG_MINunsigned longβ0long longβLLONG_MINunsigned long longβ0floatβ-FLT_MAXdoubleβ-DBL_MAXlong doubleβ-LDBL_MAX
π¦ Notes π¦
For every standard C++ floating-point type T, std::numeric_limits<T>::lowest() == -std::numeric_limits<T>::max() β like, that equality is giving for standard floats. But this does not necessarily have to be the case for any third-party specialization. So donβt assume, bestie. π
π₯ Example π₯
Demonstrates min(), max(), and lowest() for floating-point types. The page literally says // Run this code, so run it, bestie:
#include <iostream>
#include <limits>
#include <string_view>
template<typename T>
void print_twice(std::string_view type, T value)
{
std::cout << '\t' << type << ": "
<< std::defaultfloat << value << " or "
<< std::hexfloat << value << '\n';
}
int main()
{
// min()
std::cout << "std::numeric_limits<T>::min():\n";
print_twice("float", std::numeric_limits<float>::min());
print_twice("double", std::numeric_limits<double>::min());
print_twice("long double", std::numeric_limits<long double>::min());
// lowest()
std::cout << "std::numeric_limits<T>::lowest():\n";
print_twice("float", std::numeric_limits<float>::lowest());
print_twice("double", std::numeric_limits<double>::lowest());
print_twice("long double", std::numeric_limits<long double>::lowest());
// max()
std::cout << "std::numeric_limits<T>::max():\n";
print_twice("float", std::numeric_limits<float>::max());
print_twice("double", std::numeric_limits<double>::max());
print_twice("long double", std::numeric_limits<long double>::max());
}
π» Output π»
std::numeric_limits<T>::min():
float: 1.17549e-38 or 0x1p-126
double: 2.22507e-308 or 0x1p-1022
long double: 3.3621e-4932 or 0x8p-16385
std::numeric_limits<T>::lowest():
float: -3.40282e+38 or -0x1.fffffep+127
double: -1.79769e+308 or -0x1.fffffffffffffp+1023
long double: -1.18973e+4932 or -0xf.fffffffffffffffp+16380
std::numeric_limits<T>::max():
float: 3.40282e+38 or 0x1.fffffep+127
double: 1.79769e+308 or 0x1.fffffffffffffp+1023
long double: 1.18973e+4932 or 0xf.fffffffffffffffp+16380
π See also π
min[static]β returns the smallest finite value of the given type (public static member function)denorm_min[static]β returns the smallest positive subnormal value of the given floating-point type (public static member function)max[static]β returns the largest finite value of the given type (public static member function)
okay thatβs the tea, bestie: this iconic page comes from source http://cppreference.com, version/date 2024.06.10, and the manual page is std::numeri...mits::lowest(3). periodt π
π
π¦ 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