Swapping the contents of two variable is an elementary task that is often met in daily programming. There are two generic strategies to do that for general types.
Continue reading “A generic swap
implementation”
Month: October 2010
A generic
Detecting integer overflow II
In an earlier post we came up with a general solution to check for potential under- or overflow in an integer addition. On most modern architectures this can be done more efficiently, even when assuming that there are no special instructions that capture overflow bits or such.
Continue reading “Detecting integer overflow II”
Detecting integer overflow I
A recent discussion on stackoverflow has shown that detecting integer overflow without provoking undefined behavior need some reflection, and that the quick answers are not necessarily the best ones.
Continue reading “Detecting integer overflow I”