Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 v7 ucbtopaz-1.8; site ucbtopaz.CC.Berkeley.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!ucbvax!ucbtopaz!mwm From: mwm@ucbtopaz.CC.Berkeley.ARPA Newsgroups: net.lang.c Subject: How big is an int, and other oddities. Message-ID: <778@ucbtopaz.CC.Berkeley.ARPA> Date: Thu, 28-Feb-85 14:56:08 EST Article-I.D.: ucbtopaz.778 Posted: Thu Feb 28 14:56:08 1985 Date-Received: Tue, 5-Mar-85 14:13:45 EST References: <8412@brl-tgr.ARPA> <282@talcott.UUCP> Reply-To: mwm@ucbtopaz.UUCP (Praiser of Bob) Distribution: net Organization: Missionaria Phonibalonica Lines: 33 Summary: In article <8715@brl-tgr.ARPA> gwyn@brl-tgr.ARPA (Doug Gwyn) writes: >> If your code needs 34 bit ints ... >How did you get yourself into this jam? I was looking for wierd numbers, and the range of interest (which was actually rather small) was such that the largest integer I had to deal with was ~5 billion. [Actually, this was a hypothetical case.] >Ints are only guaranteed to cover the range -32767 to +32767. >Not even long ints are guaranteed to have 34 bits of dynamic range. Since the guarantee on range isn't in K&R (or it's well hidden if it is), I take it's in the ANSI standard? >I have written a lot of C code and NEVER have had any such >word length dependencies (other than in explicitly system-dependent >code that would not make sense to try to port anyway). >I would be interested in why your code has them. The (hypothetical) dependency is on magnitude, not length per se. For a less esoteric number on a more esoteric machine, suppose you needed to deal with magnitudes around half a million. How do you declare the variables? Int isn't big enough on most machines, and long isn't big enough in at least one K&R compiler [this compiler has sizeof(short) == sizeof(int) == sizeof(long) == 18 bits. K&R requires only sizeof(short) <= sizeof(int) <= sizeof(long)]. If the proposal that had started this were in use, you could declare them as "int20" or thereabouts, thus forcing them into something with at least 20 magnitude bits. If the compiler didn't support ints that big, the compile of the program would fail on the decleration.