Hacker News new | ask | show | jobs
by ChrisRR 321 days ago
Nah it's just whatever is most appropriate for your implementation. Overflow and wrap around is possible whether you use signed or unsigned.

As I say to some more junior devs, check whether the maths is correct and then do it, don't do it and then check if it was wrong

1 comments

My suggestion is straight from the C++ guidelines by Bjarne Stroustrup and Herb Sutter (ES.102: Use signed types for arithmetic), for reasons that you don't seem to grasp.
There's a reason they're guidelines and not rules. Use whatever is most appropriate for your use case