Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::numeric_limits<T>::infinity

      From cppreference.com
      <cpp‎ |types‎ |numeric limits
       
       
      Utilities library
       
       
      std::numeric_limits
      Static constants
      Static member functions
      numeric_limits::infinity
      Helper types
       
      static T infinity()throw();
      (until C++11)
      staticconstexpr T infinity()noexcept;
      (since C++11)

      Returns the special value "positive infinity", as represented by the floating-point typeT. Only meaningful ifstd::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.

      [edit]Return value

      Tstd::numeric_limits<T>::infinity()
      /* non-specialized */T()
      boolfalse
      char0
      signedchar0
      unsignedchar0
      wchar_t0
      char8_t(since C++20)0
      char16_t(since C++11)0
      char32_t(since C++11)0
      short0
      unsignedshort0
      int0
      unsignedint0
      long0
      unsignedlong0
      longlong(since C++11)0
      unsignedlonglong(since C++11)0
      floatHUGE_VALF
      doubleHUGE_VAL
      longdoubleHUGE_VALL

      [edit]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

      [edit]See also

      [static]
      identifies floating-point types that can represent the special value "positive infinity"
      (public static member constant)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/types/numeric_limits/infinity&oldid=148439"

      [8]ページ先頭

      ©2009-2025 Movatter.jp