Skip to main content
12 events
when toggle format what by license comment
Jul 8, 2024 at 13:09 comment added gnasher729 @JörgWMittag When I learned Fortran, the compiler was allowed to use any mathematically equivalent expression. In C, you can allow the compiler to calculate multiple operations in a different way if the result has a single rounding error, this allows fused multiply-add, but also allows replacing x + y - y with x, or x+x+x+x+x+x+x with 7*x.
S Jul 7, 2024 at 22:03 history suggested CommunityBot CC BY-SA 4.0
Fix a typo; add non-breaking spaces before one-letter and one-digit words; italicize variables (m and e)
Jun 23, 2024 at 14:56 review Suggested edits
S Jul 7, 2024 at 22:03
Jun 17, 2020 at 16:24 vote accept Voitcus
Sep 23, 2015 at 18:29 comment added Reinstate Monica For summation don't bother sorting - instead use the asymptotically faster Kahan summation algorithm, which has fewer pathological issues than adding sorted lists.
Sep 18, 2015 at 9:25 history edited Jules CC BY-SA 3.0
deleted 144 characters in body
Sep 18, 2015 at 9:25 comment added Jules I stand corrected. I just looked up the Java spec, which specifically warns not to reorder floating point expressions unless the result can be proved identical. I assume other languages are similar.
Sep 18, 2015 at 9:15 comment added Jörg W Mittag "every language I'm familiar with allows the compiler to reorder the terms for efficiency" – No language I am familiar with allows compiler optimizations to change the result of the program.
Sep 18, 2015 at 9:08 comment added Jules No observations - I just tend to prefer not to rely on what is basically an implementation detail.
Sep 18, 2015 at 9:01 comment added 5gon12eder I couldn't observe compilers doing much evil here. While the language might not forbid it, good compilers are conservative enough not to mess with your floating point expressions assuming you know what you're doing. Did you make different observations?
Sep 18, 2015 at 8:53 comment added Mandrill Yes, this makes a huge difference in the accuracy of the result summation.
Sep 18, 2015 at 8:47 history answered Jules CC BY-SA 3.0