News for hackers. Stuff that matters.
Re:Using signed or unsigned int by default in C (2015) by cannam on Tuesday August 23, 2022 @02:02PM (#32568677)
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/)

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.

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".