Signed char - What Foolishness Is This!

Henry Spencer henry at utzoo.UUCP
Tue Oct 21 05:06:19 AEST 1986


> 1)      Do other C compilers make 'char' a signed quantity by default?

Yes.  Almost any C compiler for machines like the PDP11, the VAX, the
8088, and so forth, will.

> 2)      What possible justification is there for this default?  Is not
> 'char' primarily a logical (as opposed to mathematical) quantity?  ...

The problem started with the PDP11, the first machine C was implemented
on.  A minor quirk of the 11 made it substantially more efficient to
manipulate characters as signed entities.  This hardware quirk has been
carried over, unfortunately, into a good many newer machines that have
imitated the 11 to some degree.  Compilers for these machines have a
choice of generating inefficient code or using signed characters.  Since
any decent C documentation warns you that the signedness or lack thereof
of characters is not portable, this is considered legitimate.

I believe Dennis is on record as mildly regretting the original decision
to go along with the hardware's prejudices, but it's a bit late now.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,decvax,pyramid}!utzoo!henry



More information about the Comp.lang.c mailing list