std::numeri...ts::infinity(3)
π¦ std::numeric_limits::infinity π¦
okay so this page is from the C++ Standard Libary manual β yep, that exact manual name is in the header, no cap β and itβs all about std::numeric_limits::infinity. Itβs giving very niche but very iconic C++ energy. π
πΈ NAME πΈ
std::numeric_limits::infinity β std::numeric_limits::infinity. Yes bestie, the name is literally the same thing twice; the manual page said what it said and I respect it.
β¨ Synopsis β¨
static T infinity() throw(); (until C++11)
static constexpr T infinity() noexcept; (since C++11)
So this returns the special value "positive infinity", as represented by the floating-point type T. Itβs only meaningful if std::numeric_limits<T>::has_infinity == true. In IEEE 754 β the most common binary representation of floating-point numbers β the positive infinity is the value with all bits of the exponent set and all bits of the fraction cleared. Slay, bit patterns. π₯
π Return value π
Hereβs the exact return-value map, every single row, no skipping, periodt:
Tβstd::numeric_limits<T>::infinity()/* 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 C++11) β0floatβHUGE_VALFdoubleβHUGE_VALlong doubleβHUGE_VALL
π Example π
// Run this code
#include <iostream>
#include <limits>
int main()
{
double max = std::numeric_limits<double>::max();
double inf = std::numeric_limits<double>::infinity();
if (inf > max)
std::cout << inf << " is greater than " << max << '\n';
}
π Output π
inf is greater than 1.79769e+308
π«Ά See also π«Ά
has_infinityβ identifies floating-point types that can represent the special value"positive infinity"; itβs marked[static]and is a public static member constant.
made with π by your C++ group-chat bestie Β· source: cppreference.com Β· version/date: 2024.06.10 Β· and yes, std::numeric_limits::infinity ate, 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