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

If you are using C or C++, you need to be extremely careful with signed integers, even when working modulo. Their overflow is undefined.


Is that due to the division taking place like the parent mentions, or something else?


Due to how C and C++ are defined in their standards.

The reason behind that is so that the compiler is allowed to assume that expressions like (x + 1 > x) are true, and thus can optimise more.




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

Search: