What are positive and negative infinity for different data types in c++, are they represent maximum and minimum limit of a type? or positive infinity is not a finite value.
can some explain this positive and negative infinity paradigm, or give me some good references to learn about it.
double has an infinite value if std::numeric_limits<double>::has_infinity returns true. This is the case on most systems nowadays.
Infinity is not like finite values, and follows it's own rules. Not sure how much is specified in the C++ standard but this is how it usually works
+infinity + any finite value = +infinity
-infinity + any finite value = -infinity
+infinity + +infinity = +infinity
-infinity + -infinity = -infinity
+infinity + -infinity = NaN
+infinity * any positive value = +infinity
+infinity * any negative value = -infinity
-infinity * any positive value = -infinity
-infinity * any negative value = +infinity
+infinity * 0 = NaN
-infinity * 0 = NaN
NaN stands for not a number and is a special value that represents that the result doesn't make sense. It has the peculiar property that if you compare it to anything else, even itself, using any of the relational operators it will always return false.