Xiao Fat said swift12------Swift in judging Nan

Source: Internet
Author: User
Tags square root
Error description

Today, I'm getting a objective-c player, and I've got a play time. Nan, which appears as Nan after the video has finished playing, is the abbreviation for not a number. NaN is used to handle error conditions in calculations, such as 0.0 divided by 0.0 or the square root of a negative number. As can be seen from the table above, for single-precision floating-point numbers, NaN is expressed as an exponent of Emax + 1 = 128 (exponential field is all 1), and the Mantissa field is not equal to zero floating-point number. The IEEE standard does not require a specific mantissa field, so NaN is not actually one, but a family. Different implementations can freely select the value of the Mantissa field to express NaN, such as a constant Float.nan in Java can be expressed as a floating-point number of 01111111110000000000000000000000, where the first bit of the Mantissa field is 1 and the remainder is 0 (regardless of the hidden one) , but this depends on the hardware architecture of the system. Java even allows programmers to construct their own NaN values (via the Float.intbitstofloat () method) with a specific bit pattern. For example, a programmer can use a specific bit pattern in this custom NaN value to express certain diagnostic information. How to handle Nan errors. use isNaN (X) in OC to judge the X.isnan in Swift to determine the book address: HTTP://WWW.JIANSHU.COM/P/30E10475B4AA

Related Article

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.