3 ms·
Do signed types not also "break trivial math" like that, just at a different boundary? Genuine question. (The 0 boundary is obviously going to be more commonly
by mattdw 11y ago
Do signed types not also "break trivial math" like that, just at a different boundary? Genuine question. (The 0 boundary is obviously going to be more commonly hit than the 2^32 boundary, but nonetheless.)
- mohawk 11y agoSigned types have the same "wraparound" problem, i think the OP meant that they don't have this problem at the zero boundary.
- zvrba 11y agoYes, except that you're far more often operating at the 0 boundary instead of at the INT_MIN / INT_MAX boundaries. Also note that C only half-heartedly supports objects larger than SIZE_MAX/2: relevant quote from http://en.cppreference.com/w/cpp/types/ptrdiff_t http://en.cppreference.com/w/cpp/types/ptrdiff_t "If an array is so large (greater than PTRDIFF_MAX elements, but less than SIZE_MAX bytes), that the difference between two pointers may not be representable as std::ptrdiff_t, the result of subtracting two such pointers is undefined. "