Hacker News new | past | comments | ask | show | jobs | submit login

The article touches on this, since its an important realization. In C, however, if the integers are not unsigned, the add/sub version exhibits UB on overflow, because C unnecessarily ties signed/unsignedness with overflow behavior (UB, two's complement, etc.).

Not that this is important, but could hint why this trick is more often shown with XOR than with add/sub.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: