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.

Thank you

can some explain this positive and negative infinity paradigm, or give me some good references to learn about it.

Thank you

so for integral types, it doesent have infinite value rather we can use

for floating types, it has a infinite value which can be represented by

am i right?

`std::numeric_limits<``int`>::max();

to get the maximum value of the intfor floating types, it has a infinite value which can be represented by

`std::numeric_limits<``double`>::infinity();

am i right?

Last edited on

double has an infinite value if

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.

`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

Last edited on

Topic archived. No new replies allowed.