Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Absolute size of 'short' Message-ID: <1988Aug2.234117.26042@utzoo.uucp> Organization: U of Toronto Zoology References: <214@ISIDAPS5.UUCP> Date: Tue, 2 Aug 88 23:41:17 GMT 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? No. >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. For unsigned numbers this would work, *if* you can find an unsigned size that is two bytes long. There are no guarantees at all about that. (For example, I believe there's a C compiler for the pdp10, and shorts would pretty well have to be either 18 or 36 bits there. What they are on a 64-bit machine like a Cray, I have no idea, but I wouldn't count on them being 16.) I think the most portable way is to use (perhaps unsigned) long and do an "&0xffff" at strategic places. -- MSDOS is not dead, it just | Henry Spencer at U of Toronto Zoology smells that way. | uunet!mnetor!utzoo!henry henry@zoo.toronto.edu