Path: utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!claris!drc From: drc@claris.UUCP (Dennis Cohen) Newsgroups: comp.lang.c Subject: Re: Absolute size of 'short' Keywords: unsigned wrap-around Message-ID: <4456@claris.UUCP> Date: 2 Aug 88 14:24:44 GMT References: <214@ISIDAPS5.UUCP> Reply-To: drc@claris.UUCP (Dennis Cohen) Organization: Claris Corporation, Mountain View CA Lines: 23 In article <214@ISIDAPS5.UUCP> mike@ISIDAPS5.UUCP (Mike Maloney) writes: >Is the size of a (signed or unsigned) short integer guarenteed to >be two bytes? I need to manipulate and compare some unsigned ints >modulo 65536. It would be clean and convenient to just let the >machine handle my wrap-around from 0 to 0xffff and verse-vica. > Sorry, but the answer is "No". As a matter of fact, it can't even be guaranteed between compilers for the same piece of iron. An example is the Megamax C compiler for the Mac (and I think the Amiga as well) defines a short to be 8 bits, an int to be 16, and a long is 32; the other four compilers that I've used on the Mac define a short to be 16 bits. The only thing that is supposed to be guaranteed is: sizeof(short) <= sizeof(int) <= sizeof(long) You might even find some where they're all the same size (I seem to recall a compiler for CP/M which did that). Dennis Cohen Claris Corp. ------------ Disclaimer: Any opinions expressed above are _MINE_!