Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::numeric_limits<T>::lowest

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

      Returns the lowest finite value representable by the numeric typeT, that is, a finite valuex such that there is no other finite valuey wherey< x. This is different fromstd::numeric_limits<T>::min() for floating-point types. Only meaningful for bounded types.

      Contents

      [edit]Return value

      Tstd::numeric_limits<T>::lowest()
      /* non-specialized */T()
      boolfalse
      charCHAR_MIN
      signedcharSCHAR_MIN
      unsignedchar0
      wchar_tWCHAR_MIN
      char8_t(since C++20)0
      char16_t0
      char32_t0
      shortSHRT_MIN
      unsignedshort0
      intINT_MIN
      unsignedint0
      longLONG_MIN
      unsignedlong0
      longlongLLONG_MIN
      unsignedlonglong0
      float-FLT_MAX
      double-DBL_MAX
      longdouble-LDBL_MAX

      [edit]Notes

      For every standard C++ floating-point typeTstd::numeric_limits<T>::lowest()==-std::numeric_limits<T>::max(), but this does not necessarily have to be the case for any third-party specialization.

      [edit]Example

      Demonstratesmin(),max(), andlowest() for floating-point types:

      Run this code
      #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<longdouble>::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<longdouble>::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<longdouble>::max());}

      Output:

      std::numeric_limits<T>::min():float: 1.17549e-38 or 0x1p-126double: 2.22507e-308 or 0x1p-1022long double: 3.3621e-4932 or 0x8p-16385std::numeric_limits<T>::lowest():float: -3.40282e+38 or -0x1.fffffep+127double: -1.79769e+308 or -0x1.fffffffffffffp+1023long double: -1.18973e+4932 or -0xf.fffffffffffffffp+16380std::numeric_limits<T>::max():float: 3.40282e+38 or 0x1.fffffep+127double: 1.79769e+308 or 0x1.fffffffffffffp+1023long double: 1.18973e+4932 or 0xf.fffffffffffffffp+16380

      [edit]See also

      [static]
      returns the smallest finite value of the given non-floating-point type, or the smallest positive normal value of the given floating-point type
      (public static member function)[edit]
      [static]
      returns the smallest positive subnormal value of the given floating-point type
      (public static member function)[edit]
      [static]
      returns the largest finite value of the given type
      (public static member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/types/numeric_limits/lowest&oldid=148435"

      [8]ページ先頭

      ©2009-2025 Movatter.jp