3 ms·
> Unsigned int should be used instead of int for "num", but many programmers use int as a generic type for everything. Yes, this is very common. For example, G
by petters 8y ago
> Unsigned int should be used instead of int for "num", but many programmers use int as a generic type for everything.
Yes, this is very common. For example, Google requires that C++ code always uses int instead of unsigned.
- raverbashing 8y agoYeah, this is stupid. If the language creators put a feature there, use it. I really don't buy the love that some have for using signed variables when they don't make sense. As a start, you only need one comparison to check if it's within range, as it's always > 0
- andrewflnr 8y agoNot using a feature because it's broken by default is perfectly valid. All those style guides that mandate signed ints do so because someone got burned by an overflow that wasn't caught.
- raverbashing 8y agoUnsigned are not broken by default, and I've been bitten much more by ints that overflow and go negative. Funny how that's not "broken by default" (it isn't) to the same people.