2 ms·
Mostly just a joke at C's expense. When reviewing C code, any time the sign-bit gets touched I consider the danger zone to have been entered (especially in the
by Retr0id 4y ago
Mostly just a joke at C's expense. When reviewing C code, any time the sign-bit gets touched I consider the danger zone to have been entered (especially in the context of parsing data). Limiting the range of ints is a good defensive programming tactic.
As another commenter points out, the real reason is about practicality - some languages like Java don't natively support unsigned ints.
- Cloudef 4y agoMaybe I'm old, but i dont get it. I'd say signed is more dangerous as the overflow is undefined. And if you read to unsigned, you are just wasting range.
- Retr0id 4y agoYes, that's the point. Signed ints are a potential footgun, which can be partially mitigated by limiting the range to 0 - 2^31-1. Good specs pre-emptively mitigate implementation bugs.
- deleted 4y ago[deleted]