Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!linus!cca!ima!johnl
From: johnl@ima.UUCP
Newsgroups: net.lang.c
Subject: Re: type casting problem - (nf)
Message-ID: <335@ima.UUCP>
Date: Fri, 10-Jun-83 18:35:49 EDT
Article-I.D.: ima.335
Posted: Fri Jun 10 18:35:49 1983
Date-Received: Sat, 11-Jun-83 12:15:29 EDT
Lines: 24

#R:decvax:-11200:ima:15900008:000:997
ima!johnl    Jun 10 12:28:00 1983

Some more recent C compilers implement an "unsigned char" data type.
Characters are never required to be signed, the manual explicitly says
that it's machine dependent.

So, in any case, the morally correct thing to do to ensure unsigned
characters is to declare your pointer to them to be "unsigned char."  Of
course, this won't work on half of the C compilers that really exist.  If
you want to be sure, you have to write something like:

	i = *cp++ & 0377;

This is clearly an artifact of C being used mostly on PDP-11s in its
early years.  The 11 is the only machine around (that I know of) that
prefers signed chars, due to sign extension in the "mov" instruction.
Some machines prefer unsigned chars, e.g. the IBM 370 series.  Some swing
either way, e.g. the Vax and the 8086.  I expect that as Unix runs
predominantly on other than 11's and Vaxen, signed characters will wither
away.

John Levine, decvax!yale-co!jrl, ucbvax!cbosgd!ima!johnl,
{research|alice|allegra|floyd|amd70}!ima!johnl