How many decimal places can double-Type Floating-point numbers be precise ?, Double POINT

Source: Internet
Author: User

How many decimal places can double-Type Floating-point numbers be precise ?, Double POINT

Question 2:How many decimal places can double-Type Floating-point numbers be precise? Or is this question worth discussing?

Since double is a floating point, its decimal point positionIs floatingSo it is hard to say that the double type can be precise to the number of digits after the decimal point. Generally, this issue about precision is represented by the number of digits that can be expressed by the valid number (decimal. The 8-byte (64-bit) double that follows the IEEE Standard can represent the number of valid digits: 15 ~ 16

Test one:

#include <stdio.h>int main(){    printf("%.20lf",1.0/3.0);}

Result:

It can be seen that the number at the decimal point (valid number) is distorted, so it should be 16 digits.

Question 3:What are the maximum and minimum positive values of double Floating Point Numbers? (Not necessarily accurate)

This method is almost unknown:

#include <stdio.h>int main(){    double a = 0, b = 0;    while(a<=b){        a = b;        b++;    }    printf("%f",a);}

Question 4:Logical operator no. "&", "|", "! "What is the relative priority?

#include <stdio.h>int main(){    int a = 0, b = 1, c = 1;    printf("%d",a&&b||c);}

The output value is 1, which is visible.

#include <stdio.h>int main(){    int a = 0, b = 0;    printf("%d",!a&&b);}

The output is 0, visible!> &&

To sum up!> &> |

Note that the logical operators in C language are short-circuit operators. Once the value of the entire expression can be determined, the computation will not continue.

 


The number of decimal places that can be precise to a double floating point number.

6 digits

Float and double types are precise to decimal places

Single precision float 32 bit approx +-(E-38 ~ E38)
Double 64 bit approx +-(E-308 ~ E308)

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.