C + + code snippet Six

Source: Internet
Author: User

The pros and cons of the Primer Plus floating point:
1 voidtest109 ()2 {3      floatA=2.34e+22f;4      floatb=a+1.0f;5cout<<"A ="<<a<<Endl;6cout<<"b-a="<<b-a<<Endl;7}
Output:
A =2.34e+022
B-a=0================================2.34e+22 is a number that has 23 digits to the left of the decimal point. Add 1, which is the 23rd digit plus 1, but float can only represent the first 6 or the first 7 bits in the number, so modifying the 23rd bit value has no effect.

C + + code snippet Six

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.