A generic swap implementation

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”

Advertisements

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”