4 ms·
>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
by xxs 5y ago
>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.
- int_19h 5y agoAnd yet the default type for variables and function arguments in C was (before it got deprecated) signed int, not unsigned.
- xxs 5y agosigned/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.
- int_19h 5y agoIf 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.