4 ms·
What is the signed value of 0-UINT_MAX? There is no way to handle this issue on machine types, unless part of the range is reserved for overflow and checked. B
by judk 12y ago
What is the signed value of 0-UINT_MAX?
There is no way to handle this issue on machine types, unless part of the range is reserved for overflow and checked. But performance nuts intentionally discard safety for performance.
- srean 12y agoAs I suggested there should not be a '-' that returns unsigned. If you want to cast it back to unsigned you would have to do it explicitly, and ideally a checked cast, though I am not averse to a more verbose unchecked cast. I am not averse to binary operators with wrap around / modulo arithmetic, but they should be look different from the usual '+', '-' etc. This only applies to languages that do not allow overloading operators.
- gweinberg 12y agoI agree. It seems to me that saying unsigned - unsigned is unsigned is just asking for trouble.