3 ms·
If you are using C or C++, you need to be extremely careful with signed integers, even when working modulo. Their overflow is undefined.
by eru 6y ago
If you are using C or C++, you need to be extremely careful with signed integers, even when working modulo. Their overflow is undefined.
- boston_clone 6y agoIs that due to the division taking place like the parent mentions, or something else?
- eru 6y agoDue 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.