Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::numeric_limits<T>::denorm_min

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

      Returns the minimum positivesubnormal value of the typeT, ifstd::numeric_limits<T>::has_denorm!=std::denorm_absent, otherwise returnsstd::numeric_limits<T>::min() for floating point types andT() for all other types. Only meaningful for floating-point types.

      [edit]Return value

      Tstd::numeric_limits<T>::denorm_min()
      /* 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(since C++11)0
      floatFLT_TRUE_MIN (\(\scriptsize 2^{-149}\)2-149
      if
      std::numeric_limits<float>::is_iec559 istrue)
      doubleDBL_TRUE_MIN (\(\scriptsize 2^{-1074}\)2-1074
      if
      std::numeric_limits<double>::is_iec559 istrue)
      longdoubleLDBL_TRUE_MIN

      [edit]Example

      Demonstates the underlying bit structure of thedenorm_min() and prints the values:

      Run this code
      #include <cassert>#include <cstdint>#include <cstring>#include <iostream>#include <limits> int main(){// the smallest subnormal value has sign bit = 0, exponent = 0// and only the least significant bit of the fraction is 1std::uint32_t denorm_bits=0x0001;float denorm_float;std::memcpy(&denorm_float,&denorm_bits, sizeof(float)); assert(denorm_float==std::numeric_limits<float>::denorm_min()); std::cout<<"float\tmin()\t\tdenorm_min()\n";std::cout<<"\t"<<std::numeric_limits<float>::min()<<'\t';std::cout<<std::numeric_limits<float>::denorm_min()<<'\n'; std::cout<<"double\tmin()\t\tdenorm_min()\n";std::cout<<"\t"<<std::numeric_limits<double>::min()<<'\t';std::cout<<std::numeric_limits<double>::denorm_min()<<'\n';}

      Possible output:

      floatmin()denorm_min()1.17549e-381.4013e-45doublemin()denorm_min()2.22507e-3084.94066e-324

      [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]
      identifies the denormalization style used by the floating-point type
      (public static member constant)[edit]
      [static](C++11)
      returns the lowest finite value of the given type, i.e. the most negative value for signed types,0 for unsigned types
      (public static member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/types/numeric_limits/denorm_min&oldid=148443"

      [8]ページ先頭

      ©2009-2025 Movatter.jp