2 ms·
> True yet less likely because most integer values appearing in programs are small, and so underflows are more common than overflows. That's a dangerous argume
by cesarb 4y ago
> True yet less likely because most integer values appearing in programs are small, and so underflows are more common than overflows.
That's a dangerous argument. The values might be small, until an attacker provides a large one. Your code has to work properly with all possible values, regardless of which ones are more "likely" or "common". In my experience, unsigned makes this simpler, since there are only two cases to consider (zero or positive) instead of four (zero, positive, negative, and INT_MIN); I've expanded on this in a comment here an year ago (https://news.ycombinator.com/item?id=29770689 https://news.ycombinator.com/item?id=29770689).
- pron 4y agoThat's one way of looking at it; another is that the common bugs due to underflow with small numbers themselves create more exploitable vulnerabilities. Anyway, I think your point of view is valid, but it will have to become much closer to a consensus before Java considers changing the status quo and adding unsigned types to the core language.