4 ms·
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
by Animats 10y ago
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.
- gok 10y agoDo you find a shorthand for wraparound math (like Swift's &+) so bad?