3 ms·
I agree with the content of this article, but all the same my advice is usually the opposite - for reasons that its author sets out rather well in the table in
by cannam 4y ago
I agree with the content of this article, but all the same my advice is usually the opposite - for reasons that its author sets out rather well in the table in his follow-up article (https://blog.robertelder.org/signed-or-unsigned-part-2/ https://blog.robertelder.org/signed-or-unsigned-part-2/)
I wrote a little piece about this myself once (http://soundsoftware.ac.uk/c-pitfall-unsigned.html 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.
- ghoward 4y agoI 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".