Once again, I'm teaching a class where I get to answer students questions about C. Here's one I don't know the answer to: Was there a rationale behind accepting signed
as the default modifier for C? One would have thought unsigned
was the natural choice. So, was this really a design decision?
In terms of the standard (since your question is tagged as such), signed
was marked as the default because that's how it was with the C implementations that came before the standard.
The original ANSI/ISO standard mandates were to codify existing practice rather than create a new language. Hence the behaviour of pre-standard implementations was the most important factor, as per the rationale document:
The original X3J11 charter clearly mandated codifying common existing practice, and the C89 Committee held fast to precedent wherever that was clear and unambiguous.
The vast majority of the language defined by C89 was precisely the same as defined in Appendix A of the first edition of The C Programming Language by Brian Kernighan and Dennis Ritchie, and as was implemented in almost all C translators of the time. (This document is hereinafter referred to as K&R.)
If you're looking to find out why the pre-standard implementations preferred signed
, you'll probably have to look into the architecture of the PDP-n machines for which UNIX and C were originally developed.
The History of C page shows that unsigned
was actually a relative latecomer to the language, appearing sometime in the mid '70s:
During 1973-1980, the language grew a bit: the type structure gained unsigned, long, union, and enumeration types, and structures became nearly first-class objects (lacking only a notation for literals).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With