Path: utzoo!utgpu!watmath!clyde!att!rutgers!mailrus!uflorida!novavax!proxftl!twwells!bill From: bill@twwells.uucp (T. William Wells) Newsgroups: comp.lang.c Subject: Re: signed/unsigned char/short/int/long [was: #defines with parameters] Summary: you've still got it wrong Message-ID: <225@twwells.uucp> Date: 29 Nov 88 21:25:39 GMT References: <264@aber-cs.UUCP> <8982@smoke.BRL.MIL> <8983@smoke.BRL.MIL> <277@aber-cs.UUCP> Reply-To: bill@twwells.UUCP (T. William Wells) Distribution: eunet,world Organization: None, Ft. Lauderdale Lines: 71 In article <277@aber-cs.UUCP> pcg@cs.aber.ac.uk (Piercarlo Grandi) writes: : As I understand it, this means that char,short,int,long are distinct : types, whereas unsigned and signed are type modifiers. In a sense then, : the view of dpANS is that unsigned [int] and [signed] int are the same : type, only that one has a sign and the other hasn't. These are the C int-ish types the types other ways of saying the same type char signed char unsigned char signed short int short, signed short, short int unsigned short int unsigned short signed int int, signed (or nothing, in some cases) unsigned int unsigned signed long int long, signed long, long int unsigned long int unsigned long (The order of the words is irrelevant.) --- If you want to, you can think of this as types and modifiers, though the standard does not speak of them that way. If so, here is how you do it: The types: char int That's right. Only two. The modifiers: unsigned signed short long The first pair modifies char or int; the second int only. You can specify only one of each pair. --- Here are the characteristics of the types: signedness values char * * signed char signed no smaller integer range exists unsigned char unsigned no smaller unsigned range exists short signed contains signed char values unsigned short unsigned contains unsigned char values int signed contains short values unsigned unsigned contains unsigned short values long signed contains int values unsigned long unsigned contains unsigned int values * Char may be either signed or unsigned. However, it is always treated as a distinct type. The characters in the source character set are positive values, but anything else may be positive or negative. There is no relationship between char and signed or unsigned char, other than that they occupy the same amount of storage. Each unsigned type must be able to represent the positive values of its corresponding signed type. Signed and unsigned types must occupy the same amount of storage. --- Bill {uunet|novavax}!proxftl!twwells!bill