Number of precision digits for double in C++ different in windows and Linux. Why? Linux shows more than 20 non-zero precision digits

后端 未结 4 1632
[愿得一人]
[愿得一人] 2021-01-12 20:24

Just did this:

double val1=numeric_limits::max();
cout.precision(70);
cout<<\"\\nVal1: \"<

In Windows I sta

4条回答
  •  醉话见心
    2021-01-12 21:14

    The Wikipedia entry on double precision defines the bounding errors for translation between decimal digits and double values very succinctly:

    This gives from 15 - 17 significant decimal digits precision. If a decimal string with at most 15 significant decimal is converted to IEEE 754 double precision and then converted back to the same number of significant decimal, then the final string should match the original; and if an IEEE 754 double precision is converted to a decimal string with at least 17 significant decimal and then converted back to double, then the final number must match the original.

提交回复
热议问题