News for hackers. Stuff that matters.
Re:Swapping two Numbers without Temporary Variables by setuids on Thursday March 24, 2022 @09:07PM (#30797622)
> under/overflow Assuming the 2 variables are treated as unsigned ints, even with under/overflows the algorithm works, since if a=a+b overflows, then b=a-b is guaranteed to underflow, thus returning the original a. The overflowed bit is irrelevant here
Re:Swapping two Numbers without Temporary Variables by wolpoli on Friday March 25, 2022 @02:02AM (#30799099)
I never considered that this algorithm would work so well with unsigned int. Looks like I learn something new today.