4 ms·
Something like for(size_t i = 0; i <= n; i += k) { work_with(n - i); }? This sort of loop always comes up in these discussions, and I was never convinced that
by pbsd 10y ago
Something like for(size_t i = 0; i <= n; i += k) { work_with(n - i); }?
This sort of loop always comes up in these discussions, and I was never convinced that signed integers were worth it for that alone.
- Sean1708 10y agoTo be honest I think there are good arguments to both sides, and I don't think there is really a one size fits all solution here. If you use unsigned you've got to pay attention to certain corner cases, if you use signed you've got to pay attention to different corner cases, it's up to you to decide which is more common in your code.