std::numeric_limits<T>::infinity

Returns the special value “positive infinity”, as represented by the floating-point type T. Only meaningful if std::numeric_limits::has_infinity == true. In IEEE 754, the most common binary representation of floating-point numbers, the positive infinity is the value with all bits of the exponent set and all bits of the fraction cleared.

# Declarations

static T infinity() throw();

(until C++11)

static constexpr T infinity() noexcept;

(since C++11)

# Example

#include <iostream>
#include <limits>
 
int main()
{
    double max = std::numeric_limits<double>::max();
    double inf = std::numeric_limits<double>::infinity();
 
    if (inf > max)
        std::cout << inf << " is greater than " << max << '\n';
}

# See also