std::numeri...has_infinity(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

🌸 NAME 🌸

okay so this is the std::numeri...has_infinity(3) page β€” from the C++ Standard Libary manual, section 3, bestie πŸ’– and we are talking about std::numeric_limits::has_infinity, no cap.

std::numeric_limits::has_infinity β€” std::numeric_limits::has_infinity


πŸ¦‹ Synopsis πŸ¦‹

static const bool has_infinity;      (until C++11)
static constexpr bool has_infinity;  (since C++11)

The value of std::numeric_limits<T>::has_infinity is true for all types T capable of representing the positive infinity as a distinct special value. This constant is meaningful for all floating-point types and is guaranteed to be true if std::numeric_limits<T>::is_iec559 == true.


πŸ¦‹ Standard specializations πŸ¦‹

here’s the T β†’ value of std::numeric_limits<T>::has_infinity vibe check, bestie πŸ‘‡

  • /* non-specialized */ β€” false
  • bool β€” false
  • char β€” false
  • signed char β€” false
  • unsigned char β€” false
  • wchar_t β€” false
  • char8_t (since C++20) β€” false
  • char16_t (since C++11) β€” false
  • char32_t (since C++11) β€” false
  • short β€” false
  • unsigned short β€” false
  • int β€” false
  • unsigned int β€” false
  • long β€” false
  • unsigned long β€” false
  • long long (since C++11) β€” false
  • unsigned long long (since C++11) β€” false
  • float β€” usually true
  • double β€” usually true
  • long double β€” usually true

πŸŽ€ Example πŸŽ€

// Run this code

#include <iostream>
#include <limits>

int main()
{
    std::cout << std::boolalpha
              << std::numeric_limits<int>::has_infinity << '\n'
              << std::numeric_limits<long>::has_infinity << '\n'
              << std::numeric_limits<float>::has_infinity << '\n'
              << std::numeric_limits<double>::has_infinity << '\n';
}

πŸ“ Possible output πŸ“

false
false
true
true

🌈 See also 🌈

  • infinity [static] β€” returns the positive infinity value of the given floating-point type (public static member function)
  • has_quiet_NaN [static] β€” identifies floating-point types that can represent the special value "quiet not-a-number" (NaN) (public static member constant)
  • has_signaling_NaN [static] β€” identifies floating-point types that can represent the special value "signaling not-a-number" (NaN) (public static member constant)

mwah πŸ’‹ this cutie came from http://cppreference.com, dated 2024.06.10 β€” and the page is std::numeri...has_infinity(3) β€” bye bestie 🫢✨

πŸ“¦ where this page comes from