Open In App

std::numeric_limits<T>::denorm_min() in C++ with Example

Improve
Improve
Like Article
Like
Save
Share
Report

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


Last Updated : 12 Jun, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads