Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!pyramid!decwrl!sun!guy From: guy@sun.uucp (Guy Harris) Newsgroups: net.lang.c Subject: Re: Int and Char Message-ID: <5536@sun.uucp> Date: Sun, 27-Jul-86 01:20:58 EDT Article-I.D.: sun.5536 Posted: Sun Jul 27 01:20:58 1986 Date-Received: Sun, 27-Jul-86 09:37:43 EDT References: <1004@zog.cs.cmu.edu> Organization: Sun Microsystems, Inc. Lines: 23 > I agree this is a major oversight in portability, but I think the main > reason that there is no 'signed' adjective for chars is that the > representation and interpretation for chars is too machine dependent. The trouble with this theory is that there *is* a "signed" adjective for "char"s in ANSI C; somebody recently claimed here that some C compiler even implemented it. > That is, a machine can not be told to interpret chars as signed if it only > knows about unsigned reprsentations. Oh, yes it can! It may not be *convenient*, but it's certainly *possible*. Consider the sequence load byte into register if (high-order bit of that byte == 1) OR in a mask of 1's to set all bits above it You now have that "char" in the register, sign-extended. -- Guy Harris {ihnp4, decvax, seismo, decwrl, ...}!sun!guy guy@sun.com (or guy@sun.arpa)