KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm currently reading through the excellent Library for Double-Double and Quad-Double Arithmetic paper, and in the first few lines I notice they perform a sum in the following way: std::pair<double, double> TwoSum(double a, double b) { double s = a + b; double v = s - a; double e = (a - (s - v)) + (b - v); return std::make_pair(s, e); } The calculation of the error, e , relies on the fact that the calculation follows that order of operations exactly because of the non-associative properties of IEEE-754 floating point math. If I compile this within a modern optimizing C++ compiler (e.g. MSVC or gcc), can I be ensured that the compiler won't optimize out the way this calculation is done? Secondly, is this guaranteed anywhere within the C++ standard?
Tags (comma-separated)
Save Edits
Cancel