News for hackers. Stuff that matters.
Re:Fast integer overflow detection (2012) by TheLoneWolfling on Sunday December 14, 2014 @05:28PM (#8749799)
Generally you'll be doing this anyways (as you'll be storing it with a bit to tag if it is a pointer).

However, it is... interesting... that a language that is so low-level does not have any simple construct for doing this, especially seeing how trivial it is in x86 assembly (add the numbers, then check the overflow flag).

And saying "just don't used signed arithmetic" misses the point. If a "general-purpose" programming language cannot do something that is trivial in the next layer down, and that occurs as commonly as wanting to do something if there would be an overflow, I am inclined to blame the language, not the coder.

Re:Fast integer overflow detection (2012) by RaleyField on Sunday December 14, 2014 @05:59PM (#8749901)
> especially seeing how trivial it is in x86 assembly (add the numbers, then check the overflow flag)

I'm no expert, especially not on modern x86 processors or compilers for them, but I suspect it isn't so trivial as scattering such instructions may affects branch predictor tables and indirectly degrade performance in other parts of code.

Re:Fast integer overflow detection (2012) by TheLoneWolfling on Sunday December 14, 2014 @07:06PM (#8750059)
You require one branch regardless, and the trivial version is one branch, i.e. already at the minimum amount of branches.