SoFunction
Updated on 2025-03-05

A summary of the definition of invalid value of C++ floating point number and invalid value judgment

In actual calculations, floating-point invalid data may appear. The formatted output to the file is 1.79769e+308, and the output to the interface is a large string of data. No matter which of these two methods is not very convenient when reading or searching. When encountering floating-point data invalid during development, it is worth determining.

Invalid value definitionas follows:
#define InvalidDouble *(double*)("\xff\xff\xff\xff\xff\xff\xef\x7f")
double  price;
......... (Save the calculation steps)
price=GetPrice(); //Get data

The floating point type isMethod for determining invalid data
(price==InvalidDouble)?0:price