Are there any generally-applicable tips to reduce the accumulation of floating-point roundoff errors in C or C++? I’m thinking mainly about how to write code that gets compiled into optimal assembly language instructions, although strategies on overall algorithm design are also welcome.
Are there any generally-applicable tips to reduce the accumulation of floating-point roundoff errors in
Share
The only trick I know is that when you’re summing a bunch of numbers, don’t do them one at a time – group them so that the additions are on numbers of approximately the same magnitude. To sum a huge array of random numbers for example, recursively sum by pairs.