Search code examples
c++gdbnumeric-limits

What is inf in gdb


I am debugging a C++ program. There is a variable x of type double, gdb prints its value as inf. Yet, the following expression returns false even though the value of x did not change

x == std::numeric_limits<double>::max()

When gdb says inf, does it not mean the max possible value for this type (double)? If not, then what does it mean?


Solution

  • It means that x == std::numeric_limits<double>::infinity().

    A floating point implementation doesn't necessarily have to support infinity but the common one - IEEE754 - does.

    From C++11 onwards, you can use std::isinf(x) to test if a floating point number is infinite.