문제

I have done a C program to compute a solution of a differential equation along path. The code has been done using double precision.

I do not understand why I do get an error of 10^-21 (absolute error) only. It is supposed double precision gives only about 16 digits of precision.

The error is computed but doing the difference of a constant that it is known to be invariant during the mathematical process to find the solution. The details of this are not relevant. My question is only how is possible to get less error that the supposed limit of precision used.

Using gcc I have the following precision parameters:

Min Epsilon Double: 0.000000000000000222044604925031
Digits mantissa (bit precission) double: 53

Thanks a lot.

도움이 되었습니까?

해결책

The answer may be that you use GCC on x86/x86_64, the calculations are not too complex, so the compiler optimizes them to be processed internally in 80-bit floating point registers which have long double precision, thus giving you better results.

Or it may be that you use the word precision to describe absolute error, and when the actual values are on the order of 10-5 and the relative error is on the order of 10-16, the absolute error is on the order of 10-21.

Or something else, depending on the context. You see, the details are actually relevant.

다른 팁

Floating point values (float and double) use scientific notation in binary.

So, part of the bits used by a double are the significative (binary digits) while others are the exponents.

Check the documentation for maximum and minimum values for such types, it also specifies how close to 0 an -0 they can get.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top