CompuServe Thread

Forum unknown · Programming

Do we char?

5 messages in this thread
#117640From: John FoustApr 6, 1988 2:16 AM
Nick, it had been bugging me for weeks since we talked about this. You once asked if Standard C declared 'char' to be signed or unsigned. I had hoped it was definite. The latest C Users Journal has an article by PJ Plauger on Standard C types. Type 'char' is guaranteed to be at least eight bits. They decided in favor of efficiency, leaving the decision to the compiler writer. Presumably, the compiler writer chooses the most efficient method in terms of storage and signed-integer encoding and math on a given processor. Of course, you have type specifier keywords like 'signed' and 'unsigned' to specify signedness. Plauger mentioned that on a Cray, int, long and char are all the same size: 64 bits.
#117898From: Nick Sullivan/TransactorApr 7, 1988 11:04 PM
Thanks for the research, John. Like you, I would have preferred the signedness of char to be defined in the language specification… let the application programmer worry about fine tuning the efficiency of the code with type specifications if desired, but make the default portable. Ah, well. 64 bits? That's a heck of a char! Actually, I always thought that char was unlike int and long in being defined as having a specific size – 8 bits, not merely "at least 8 bits". Guess not.
#118017From: John FoustApr 8, 1988 4:42 PM
The standard on sizing says that char, int and long are "not larger than the next", which leaves a loophole for them to be equal sizes. I don't think it's a big deal to depend on 'signed' or 'unsigned' keywords to make the code portable.
#118017From: John FoustApr 8, 1988 4:42 PM
The standard on sizing says that char, int and long are "not larger than the next", which leaves a loophole for them to be equal sizes. I don't think it's a big deal to depend on 'signed' or 'unsigned' keywords to make the code portable.
#117898From: Nick Sullivan/TransactorApr 7, 1988 11:04 PM
Thanks for the research, John. Like you, I would have preferred the signedness of char to be defined in the language specification… let the application programmer worry about fine tuning the efficiency of the code with type specifications if desired, but make the default portable. Ah, well. 64 bits? That's a heck of a char! Actually, I always thought that char was unlike int and long in being defined as having a specific size – 8 bits, not merely "at least 8 bits". Guess not.