#QNAN, 1 #IND和1. #INF等 "Invalid" floating-point number description and its judgment

Source: Internet
Author: User
Tags bit set square root

In the GIS view found that some of the community can not be normal, through the tracking of abnormal cells to find its base station latitude and longitude of the coordinates are -1. #QNAN00000000000无效值, resulting in plot failure, these communities are new network 3G Base station, the resource data has not been maintained, The corresponding field in the database is empty, and after the tuxedo interface The data is reflected as Qnan invalid value. Before the underlying data is refined, the null value can be converted to 0 when the data is fetched, or further filtered for data when it is received.
In 1 #QNAN是一个打印呈现, Qnan refers to quiet not a number, similar floating-point errors and snan (signaling not a number), usually such as 0.0/0.0, An overflow or an invalid operation, such as a square root for a negative number, produces a representation value for the Nan result, and a description of the Nan and two floating-point errors as follows:
The valueNaN(not a number) are used to represent a value, does not represent a real number. NaN ' s are represented by a bit pattern with a exponent to all 1s and a non-zero fraction. There are two categories of Nan:qnan (Quiet nan) and Snan (signalling Nan).
AQnanis a NaN with the most significant fraction bit set. Qnan ' s propagate freely through most arithmetic. These values pops out of a operation when the are not mathematically defined.
AnSnanis a NaN with the most significant fraction bit clear. It is used to signal a exception when used in operations. Snan ' can be handy to assign to uninitialized variables to trap premature usage.
Semantically, Qnan ' s denote indeterminate operations, while Snan ' s denote invalid. If A return value was a qnan, it means that it's impossible to determine the "operation", a snan means that th e operation is invalid.
Such special floating-point numbers also have INF and Ind:inf as Infinity, representing an infinitely large number, including positive infinity and negative infinity; ind is infinitely small, but uncertain. such as 1.0/0.0 will produce an INF infinity, -1.0/0.0 will produce a negative infinity.
 
Back to the original error, this invalid data was judged by longitude and latitude valid values because the normal floating-point range is not valid for such floating-point numbers. We know that a regular floating-point number cannot be directly sentenced to 0 equals, and if the floating-point number is Nan, the IF (F==F) will get false results. However, it is not always safe to use this result to determine whether a floating-point number is Nan, such as using this macro to define #define ISNAN (x)!= (x)), which may be out of your expectation in some compilation environments. So how do you judge a particular floating-point number? Each language should be able to find the corresponding auxiliary function or class method, in the C language, you can use the int _isnan (double x), int _finite (double x), int _fpclass (double x) function in float.h to judge, The return result represents the meaning of _fpclass_snan (signaling Nan), _fpclass_qnan (Quiet nan), _fpclass_ninf (Negative infinity,–inf), _fpclass_ Pinf (Positive Infinity, +inf); in C + +, you can use the Limits class in STL: Numeric_limits::quiet_nan (), Numeric_limits::signaling_nan (), Numeric_limits::infinity () and other methods.
 
For more information, refer to the following article:
http://www.ibm.com/developerworks/cn/java/j-jtp0114/
Http://steve.hollasch.net/cgindex/coding/ieeefloat.html
Http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=integersReals2

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.