Path: utzoo!attcan!uunet!husc6!think!bloom-beacon!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP (der Mouse) Newsgroups: comp.lang.c Subject: Re: optimization (was Re: volatile) Message-ID: <1113@mcgill-vision.UUCP> Date: 18 May 88 08:07:20 GMT References: <12578@brl-adm.ARPA> <1988Mar25.172355.348@utzoo.uucp> <529@wsccs.UUCP> Organization: McGill University, Montreal Lines: 29 Posted: Wed May 18 04:07:20 1988 In article <529@wsccs.UUCP>, terry@wsccs.UUCP (Every system needs one) writes: > In article <375@m3.mfci.UUCP>, root@mfci.UUCP (SuperUser) writes: >> No, these two programs are not equivalent. When comparing an >> unsigned to a signed integer, the signed integer is first cast to >> unsigned [...] > In addition, since the size of int is defined to be the register > size, The size of an int is defined to be whatever the compiler designer wants it to be. Generally, this will be a `natural' size of the machine, such as the register size or the bus width. > unless the size of int is 8 bits, Who says a char is 8 bits? Suppose char and int are both 16 bits? (As far as I can tell, the programs are equivalent exactly when char is narrower than int.) > the unsigned char will be sign-extended to int If it gets extended at all, it will be zero-extended. Pre-ANSI, it would be zero-extended to unsigned int (generally); post-ANSI (and probably in a few pre-ANSI compilers) it will be zero-extended to signed int. der Mouse uucp: mouse@mcgill-vision.uucp arpa: mouse@larry.mcrcim.mcgill.edu