Deep C++ floating point invalid value definition and determination of the solution

  • 2020-04-01 23:35:28
  • OfStack

Invalid floating point data may appear in the actual calculation. The formatted output to the file is 1.79769e+308, and the output to the interface is a large string of data. Either way is not very convenient for reading and searching.
Invalid values are defined as follows: #define InvalidDouble *(double*)("\ XFF \ XFF \ XFF \ XFF \ XFF \xef\x7f")
A double   Price;
. (calculation steps are omitted)
Price = GetPrice (); // get data

Floating-point data is determined in the following way
(price = = InvalidDouble)? 0: price,

Related articles: