I assume that the latter value is an exact representation of the value of the double because after the 53rd decimal digit, all (1153) following decimal digits are 0.
Two thoughts:
The semantics of a calculation in MPFR is specified as follows: Compute the requested operation exactly (with “infinite accuracy”), and round the result to the precision of the destination variable, with the given rounding mode. The MPFR floating-point functions are intended to be a smooth extension of the IEEE 754 arithmetic. The results obtained on a given computer are identical to those obtained on a computer with a different word size, or with a different compiler or operating system.MPFR does not keep track of the accuracy of a computation. This is left to the user or to a higher layer (for example the MPFI library for interval arithmetic). As a consequence, if two variables are used to store only a few significant bits, and their product is stored in a variable with large precision, then MPFR will still compute the result with full precision.
Which I believe means that calculations that end up in 53-bit precision variables may (will often) yield different results from calculations done using IEEE-754 64-bit floats; because of greater accuracy at intermediate points.
In your example above 1 / 526, you posted a result of: 1.9011406844106463 7711435114653113487293012440204620361328125e-3
But the actual result (to 100 digits of precision is : 1.9011406844106463 87832699619771863117870722433460076045627376425855513307984790874524714828897338403e-3
As you can see, only the first 17 digits of the MPFR output are accurate.
As calculated with perl's doubles : 1.901140684410646 40000e-003
Ditto your 1 / 535 example: 1.869158878504672 97461032334382480257772840559482574462890625e-3
Actual (to 100 digits) : 1.869158878504672 897196261682242990654205607476635514018691588785046728971962616822429906542056074766e-3
This time only 16 digits of the MPFR output match.
With perl's doubles : 1.86915887850467 300000e-003
I'm not sure what that all means, but I did validate the 1/526 example manually, as well as calculating them with Math::BigFloat.
In reply to Re^10: subtraction issue
by BrowserUk
in thread subtraction issue
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |