in reply to Re^2: [OT] C++ mystery.
in thread [OT] C++ mystery.
to that point, why...
z.hi = H + e z.lo = e + H - z.hi z.lo = e + H - ( H + e ) z.lo = e - e
...my math may be rusty ;) ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: [OT] C++ mystery.
by BrowserUk (Patriarch) on Jun 19, 2015 at 20:35 UTC | |
The basic process at work here is the following Of course, it doesn't end there. There might already be values in those other (low) doubles; and they need to be added together along with the spillage from the hi order doubles above. But that calculation itself can result in what might be termed 'overflow' or 'carry-over'; and that needs to be added back into the high order part of the result. But that ... Hopefully, you get the picture. The sequences of additions and subtractions in that sub are meant to ensure that borrows from the high order doubles and carries from the low order doubles are sorted out and merged; with the result that you end up with 105/6 bits of precision. It -- the C++ -- appears to work; plenty of people have used it -- but I want to port (parts of) it to C; and that's caused me to look closely at it. And there is weirdness afoot. 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!
| [reply] [d/l] [select] |
|
Re^4: [OT] C++ mystery.
by bitingduck (Deacon) on Jun 20, 2015 at 00:46 UTC | |
| [reply] |
by BrowserUk (Patriarch) on Jun 20, 2015 at 01:15 UTC | |
According to this and (for me) this, that should either not happen; or at least be controllable. But then, that may not have been the case for which compiler the code was originally (or subsequently) targeted at; so it's a good thought. Thank you. 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!
| [reply] |
by bitingduck (Deacon) on Jun 20, 2015 at 03:39 UTC | |
I took a look through some of the source code you linked, and the type cast seems to be applied in particular when there's a subtraction that's obviously close to zero. I don't have enough C++ experience to know how the compilers are expected to behave on such things (even more so older versions), but I walked through a bunch of the arithmetic and there's a lot of adding and subtracting things that should either add up to zero or add up neatly to just one of the terms that was in a previous step, so I'm actually a little surprised that there aren't more oddball things in there (or at least a note about setting a compiler directive not to simplify) to keep the epsilons from getting optimized away. There are enough things that just cancel away in odd ways that I was partly looking to verify you hadn't made any typos! EDIT: in your first link it actually points out that the Intel C++ compiler does allow associativity transformations by default, so it may be a bit of legacy code to prevent that. | [reply] |
by BrowserUk (Patriarch) on Jun 20, 2015 at 13:45 UTC | |