Resolve the definition of invalid C ++ floating point numbers and the summary of the determination of invalid values

Source: Internet
Author: User

In actual computation, invalid floating point data may occur. The formatted output content to the file is 1.79769e + 308, and the output to the interface is a large string of data. Either of the two methods is not very convenient for reading and searching. It is worthwhile to judge whether the floating point data is invalid during development.

Invalid value definitionAs follows:
# Define InvalidDouble * (double *) ("\ xff \ xef \ x7f ")
Double price;
...... (The calculation step is omitted)
Price = GetPrice (); // get data

Use the following methodHow to determine Invalid Data
(Price = InvalidDouble )? 0: price

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.