Syntactic Confectionery Delight | |
PerlMonks |
Re^2: [OT] C++ mystery.by BrowserUk (Patriarch) |
on Jun 19, 2015 at 19:44 UTC ( [id://1131179]=note: print w/replies, xml ) | Need Help?? |
It looks like it's just ensuring that the return value is coerced into a double But every variable in the entire subroutine is already a double? I don't know anything about doubledouble, so perhaps it's using an extended floating point type (like long double)? No. The doubledouble class provides greater precision by using pairs of doubles (hi & lo) to hold different parts of the higher precision value. This routine adds two doubledoubles together, by extracting any 'carry' from the lo+lo and adding it into the hi+hi calculation. I'm beginning (after reading a dozen or so papers and banging my head till it hurts) to understand how it achieves that; but the one bit that has me baffled is: why does it need to cast the subtraction of one double from another double; to a double, before adding it to another double? That; along with a couple of the other calculations don't appear to make any difference to the outcome no matter what values I've tried. Normally, I might just conclude they were artifacts of time; or minor over-engineering; but the routine is attributed (copyrighted) by W. Kahan And is (apparently) an implementation of the Kahan summation algorithm. So, I'm loathed to simplify; but I'm bugged that I cannot find any reason why they are there :( With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!
In Section
Seekers of Perl Wisdom
|
|