8 ms·
Different semantics: int overflow is undefined but can handle negative values, unsigned wraps around. So you would use int if your expression can yield a negati
by zurn 11y ago
Different semantics: int overflow is undefined but can handle negative values, unsigned wraps around. So you would use int if your expression can yield a negative value.
(You can't thus check for int overflow by checking for wraparound, see http://c-faq.com/misc/intovf.html http://c-faq.com/misc/intovf.html)
- stinos 11y ago> So you would use int if your expression can yield a negative value. Of course, but as you say it yourself: if. It seems a bit too general to abandon unsigned completely because there are cases where it is not appropriate. By that logic there wouldn't be much types one can use at all.