Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!dayton!ems!mark From: mark@ems.UUCP (Mark Colburn) Newsgroups: net.lang.c,net.micro.pc Subject: Re: Signed char - What Foolishness Is This! Message-ID: <14@ems.UUCP> Date: Sun, 19-Oct-86 23:34:40 EDT Article-I.D.: ems.14 Posted: Sun Oct 19 23:34:40 1986 Date-Received: Tue, 21-Oct-86 22:16:46 EDT References: <8719@duke.duke.UUCP> <8273@sun.uucp> Organization: EMS/McGraw-Hill, Eden Prairie, MN Lines: 35 Xref: watmath net.lang.c:10772 net.micro.pc:10572 Summary: short vs. unsigned int In article <8273@sun.uucp>, guy@sun.UUCP writes: > > I can understand the desirability of allowing 'signed char' for gonzo > > programmers who won't use 'short', > > It's not a question of "gonzo programmers who won't use 'short'. It is important to note that K&R define that: char 8 or more bits short 16 or more bits Although these values may be implementation specific. On my 68020 based machine, shorts are 16 bits. When I need an 8 bit unsigned value (e.g. a byte) in my code (which happens quite frequently when you are writing software to support 8 bit CPU's) I use 'unsigned char'. I got myself into all sorts of trouble when I was first using C because I assumed that if an int is 16 bits, then a short must be 8. Right? Wrong! On the compiler that I was using, int was 16 bits and so was short. This is consistent with K&R (and, I believe, the proposed ANSI standard). Therefore, the only portable way to express a true byte (8-bit) value is with an 'unsigned int' declaration. This may still get you into trouble when you are working on a compiler that uses characters that are more than 8 bits. Don't laugh, there are some out there. It is also allowed for in the language definition. Notice that a character may be 8 or more bits. Since machines that use chars that are larger than 8 bits are relatively infrequent, I callously disregard their existence in my code. (I am sure that I will get bitten by it one of these days, but hey, gives a guy some kinda job security). -- Mark H. Colburn UUCP: ihnp4!rosevax!ems!mark EMS/McGraw-Hill ATT: (612) 829-8200 9855 West 78th Street Eden Prairie, MN 55344