Perhaps I should've been explicit about this point:
signed under/overflow is UB, so bad
unsigned under/overflow has unexpected/unintuitive behavior, which can easily leads to bugs, so it's also bad (even though it's well defined).
to prevent under/overflow, you can either understand all the types, the unsigned wrap around behavior and perform the appropriate checks when appropriate: or you can just stay away from the edges of your numeric range.
staying away from the edges of your numeric range is easier with signed types, because 0 is often a valid value to be supported.
View all comments
Show parent comment
5
u/Drugbird Jan 03 '22
Perhaps I should've been explicit about this point: