Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Deriving a bit-twiddling hack: Signed integer overflow (grack.com)
32 points by mmastrac on Dec 20, 2022 | hide | past | favorite | 5 comments


Good 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.


This seemed strangely familiar.

Nice writeup though! I like the way it derived the logic rather than just presenting the solution.


*complement


Fixed thanks!


thanks




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

Search: