Re:Don’t assume that safety comes for free: a Swift case study
by Animats on Tuesday December 06, 2016 @03:05PM
(#13117822)
Now that more languages are checking for integer overflow, it's time for integer overflow exceptions to re-appear in hardware. DEC VAX machines had this, but C didn't use them. With the hardware doing the checking in parallel, there's no performance penalty.
If you want wrap-around arithmetic (which is rare) you should have to write something like
unsigned short i,j;
i = (i + j) % 65536;
which the compiler should optimize into a no-check add. This gets you the same answer on all platforms.
If you want wrap-around arithmetic (which is rare) you should have to write something like
which the compiler should optimize into a no-check add. This gets you the same answer on all platforms.