I am trying to wrap my head around floating-point precision. Performing the following numeric operation:
275./6.*1.03692775514337
in Mathematica and C++ and taking the difference of the two results in ~0.7e-14. I expected the difference to be zero within my $MachinePrecision
of ~15.96. C++ uses double
as variable type for each number. In addition C++ and Mathematica follow the IEEE 754, which should make division and multiplication exactly rounded operations.
In general I need to know why Mathematica is rounding multiplication and division differently than my C++ program, while both should yield the same result?
For anybody interested in the C++ code:
#include <iostream>
int main() {
std::cout << std::setprecision(17);
std::cout << 275./6.*1.03692775514337 - 47.52585544407112
return(0);
}
275./6.
towards zero (on my machine) even though rounding away from zero introduces less absolute error. But what's you source of "Mathematica follow the IEEE 754"? $\endgroup$