4 ms·
Deriving a bit-twiddling hack: Signed integer overflow
- sowbug 4y ago*complement
- furyofantares 4y agothanks
- mmastrac 4y agoFixed thanks!
- ridiculous_fish 4y agoGood article. The simple way to think about this is that overflow occurs when the sign of the addends agree, and the sum has the opposite sign. The bit tricks then write themselves.
- raphlinus 4y agoThis seemed strangely familiar. Nice writeup though! I like the way it derived the logic rather than just presenting the solution.