Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You do avoid "signed overflow" in the sense of the C and C++ specifications by working on unsigned numbers. "signed overflow" is UB, "unsigned overflow" is not.

Of course you will never be able to obtain an unrepresentable value (such as -2147483649) through a workaround, and if you cast back to signed you get the wrapped result (which, indeed, may have an unexpected sign). But the point of transpiling to operations on unsigned numbers is to avoid UB, not to escape basic computational bounds.



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

Search: