Namespaces
Variants
Views
Actions

std::numeric_limits::denorm_min

From cppreference.com
< cpp‎ | types‎ | numeric limits
Revision as of 17:13, 26 August 2013 by P12 (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
 
 
 
Type support
Basic types
Fundamental types
Fixed width integer types (C++11)
Numeric limits
C numeric limits interface
Runtime type information
Type traits
Primary type categories
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
Type properties
(C++11)
(C++11)
(C++11)
(C++14)
Supported operations
Relationships and property queries
(C++11)
(C++11)
(C++11)
(C++11)
Type modifications
(C++11)(C++11)(C++11)
Type transformations
(C++11)
(C++11)
(C++11)
Type trait constants
 
 
static T denorm_min();
(until C++11)
static constexpr T denorm_min();
(since C++11)

Returns the minimum positive subnormal value of the type T, if std::numeric_limits<T>::has_denorm != std::denorm_absent, otherwise returns std::numeric_limits<T>::min(). Only meaningful for floating-point types.

Contents

[edit] Return value

T std::numeric_limits<T>::denorm_min()
/* non-specialized */ T();
bool false
char 0
signed char 0
unsigned char 0
wchar_t 0
char16_t 0
char32_t 0
short 0
unsigned short 0
int 0
unsigned int 0
long 0
unsigned long 0
long long 0
unsigned long long 0
float 2-149
if std::numeric_limits<float>::is_iec559 == true
double 2-1074
if std::numeric_limits<double>::is_iec559 == true
long double /* implementation-defined */

[edit] Exceptions

(none) (until C++11)
noexcept specification:  
noexcept
  
(since C++11)

[edit] Example

Demonstates the underlying bit structure of the denorm_min()

#include <cstdint>
#include <limits>
#include <cassert>
int main()
{
    // the smallest subnormal value has sign bit = 0, exponent = 0
    // and only the least significant bit of the fraction is 1
    uint32_t denorm_bits = 0x0001;
    float denorm_float = reinterpret_cast<float&>(denorm_bits);
    assert(denorm_float == std::numeric_limits<float>::denorm_min());
}


[edit] See also

[static]
returns the smallest finite value of the given 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
(public static member function) [edit]