Re:Using signed or unsigned int by default in C (2015)
by ghoward on Tuesday August 23, 2022 @02:09PM
(#32568787)
I think I agree with you, as much as I don't want to.
I am a C programmer, and I think I do know what I am doing. (I implemented safe, UB-free two's-complement arithmetic in C using only unsigned integers.) I prefer unsigned.
But for someone who doesn't know, as long as they're not working on anything critical, signed might be "good enough".
I wrote a little piece about this myself once (http://soundsoftware.ac.uk/c-pitfall-unsigned.html)
I suppose I would loosely characterise my view as
- if your profession is "C programmer" and you really know what you're doing, you probably want to use unsigneds most of the time
- if your profession is something else, e.g. signal processing researcher who has to translate an algorithm to C or C++, you are probably better off not using unsigneds at all.