# Description and determination of "invalid" floating point numbers such as qnan, 1. # IND and 1. # INF

Source: Internet
Author: User

In the GIS view, it is found that some cells cannot be normally displayed. By tracking abnormal cells, it is found that the coordinates of the base stations are-1. # The value of qnan00000000000 is invalid, leading to failed cell plotting. These cells are new 3G base stations, and resource data has not been maintained. The corresponding fields in the database are blank, after the tuxedo interface, the data is returned as an invalid qnan value. Before the basic data is complete, the null value can be converted to 0 when SQL is used to retrieve data, or the data can be further filtered when receiving data.
1. # qnan is a print representation, and qnan refers to quiet not
Number. Similar floating point errors include: snan (signaling not
Number). Generally, overflow or invalid operations such as 0.0/0.0 or square root of a negative number will generate a representation of Nan results. Nan and the two floating point errors are described as follows:
The Value
Nan(Not a number) is used to represent a value that does not
Represent a real number. Nan's are represented by a bit pattern with an exponent
Of all 1 s and a non-zero fraction. There are two categories of Nan: qnan (quiet
NAN) and snan (signalling Nan ).
AQnanIs a nan with
Most significant fraction bit set. qnan's propagate freely through most
Arithmetic operations. These values pop out of an operation when the result is
Not mathematically defined.
AnSnanIs a nan with the most
Significant fraction bit clear. It is used to signal an exception when used in
Operations. snan's can be handy to assign to uninitialized variables to trap
Premature usage.
Semantically, qnan's denote indeterminate operations, while
Snan's denote invalid operations. If a return value is a qnan, it means that it
Is impossible to determine the result of the operation, a snan means that
Operation is
Invalid.
Such a special floating point number is INF and ind: INF is infinity, indicating an infinite number, including positive infinity and negative infinity. Ind indicates infinitely small, but not sure. For example, 1.0/0.0 generates an INF infinity, and-1.0/0.0 generates a negative infinity.
 
Back to the initial error, the reason why the invalid data passed the latitude and longitude valid value judgment is that the regular floating point range is invalid for such floating point numbers. We know that the regular floating point number cannot be directly set to 0 or equal. If the floating point number is Nan, then if
(F = f) the system returns false. However, using this result to determine whether a floating point number is Nan is not always safe, for example, using this macro definition # define isnan (x )! =
(X ))
In some compiling environments, it may be out of your expectation. How can we determine a special floating point number? The corresponding auxiliary functions or class methods should be available in various languages. In C, int in float. h can be used.
_ Isnan (Double X), int _ finite (Double X), int _ fpclass (double
X) function. The returned results indicate: _ fpclass_snan (signaling Nan), _ fpclass_qnan (quiet
NAN), _ fpclass_ninf (negative infinity,-INF), _ fpclass_pinf (positive infinity,
+ Inf); in C ++, you can use methods such as limits class in STL: numeric_limits: quiet_nan (), numeric_limits: signaling_nan (), and numeric_limits: infinity.
 
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.