News for hackers. Stuff that matters.
Re:Almost Always Unsigned by xxs on Sunday January 02, 2022 @08:33AM (#29768570)
>The name clearly indicates that the primary feature is that it is not signed, and the logical conclusion from that is that it is not negative.

Years ago, when the names were designated the CPUs didn't even have proper signed instructions. There was a sign flag, and that was all. In that regard the unsigned was the natural CPU sympathetic type.

Re:Almost Always Unsigned by int_19h on Sunday January 02, 2022 @11:40AM (#29770207)
And yet the default type for variables and function arguments in C was (before it got deprecated) signed int, not unsigned.
Re:Almost Always Unsigned by xxs on Sunday January 02, 2022 @12:48PM (#29771262)
signed/unsigned stuff predates C, though. My (lack of) experience with C came much later, when I had used assembly for 3 different CPUs already, so no recollection of the times.
Re:Almost Always Unsigned by int_19h on Sunday January 02, 2022 @01:41PM (#29772016)
If you mean the default being signed, it's there because B - the predecessor of C - only had a signed integer (machine word) type. But note that this is about the case when the variable has no type at all - e.g. "auto x" is a signed int. They still had the choice of "int x" being equivalent to either "signed int" or "unsigned int" by default, though - since there's no backwards compatibility issue there - and chose signed.

FWIW, signed seems to be the default for most other languages from that time period, and often the only option - e.g. Algol-60 didn't have unsigned integers at all. Pascal kinda sorta did, if you defined an integer subtype with 0 as the lower bound... but the upper would still be that of signed int, and it'd behave as such. And Algol-68 called its unsigned type BITS - a pretty strong hint that they didn't think of it as arithmetic.

I'm actually kinda curious now as to when the concept of unsigned integers first appeared in a high-level programming language first.