Skip to content
Related Articles

Related Articles

std::numeric_limits<T>::denorm_min() in C++ with Example
  • Last Updated : 12 Jun, 2020

The std::numeric_limits<T>::denorm_min() function in C++ STL is present in the <limits> header file. This function is used to find the smallest non-zero denormalized value.

Header File:

#include<limits>

Template Class:

static T denorm_min() throw();
static constexpr T denorm_min() noexcept;

Syntax:

std::numeric_limits<T>::denorm_min()

Parameter: The function std::numeric_limits<T>::denorm_min() does not accept any parameter.



Return Value: The functionstd::numeric_limits<T>::denorm_min() returns the smallest nonzero denormalized value of data type T.

Below is the program to demonstrate std::numeric_limits<T>::denorm_min() in C++:

Program:




// C++ program to illustrate
// std::numeric_limits<T>::denorm_min()
#include <bits/stdc++.h>
#include <limits>
using namespace std;
  
// Driver Code
int main()
{
  
    // Print the denormalised value for
    // different data types
    cout << "For float: "
         << numeric_limits<float>::denorm_min()
         << endl;
  
    cout << "For int: "
         << numeric_limits<int>::denorm_min()
         << endl;
  
    cout << "For double: "
         << numeric_limits<double>::denorm_min()
         << endl;
  
    cout << "For long int: "
         << numeric_limits<long int>::denorm_min()
         << endl;
  
    cout << "For long double: "
         << numeric_limits<long double>::denorm_min()
         << endl;
    return 0;
}
Output:
For float: 1.4013e-45
For int: 0
For double: 4.94066e-324
For long int: 0
For long double: 3.6452e-4951

Reference: https://en.cppreference.com/w/cpp/types/numeric_limits/denorm_min

Want to learn from the best curated videos and practice problems, check out the C++ Foundation Course for Basic to Advanced C++ and C++ STL Course for foundation plus STL.  To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.
My Personal Notes arrow_drop_up
Recommended Articles
Page :