From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,INVALID_MSGID, PLING_QUERY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,4873305131bf4d94 X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,4873305131bf4d94 X-Google-Attributes: gid103376,public X-Google-Thread: fdb77,4873305131bf4d94 X-Google-Attributes: gidfdb77,public X-Google-Thread: 109fba,4873305131bf4d94 X-Google-Attributes: gid109fba,public From: kaz@helios.crest.nt.com (Kaz Kylheku) Subject: Re: How big is an int? (was: Yet another stupid language war (was: ... the only languages you need!!)) Date: 1997/11/05 Message-ID: <63r09q$q5h$1@helios.crest.nt.com>#1/1 X-Deja-AN: 287287526 References: <34557f2b.1934172@news.mindspring.com> <345F49A2.5F5DC5A0@aom.ericsson.se> <63oadj$ljc$1@helios.crest.nt.com> Organization: A poorly-installed InterNetNews site Newsgroups: comp.lang.ada,comp.lang.c,comp.lang.c++,comp.lang.java.advocacy,comp.lang.c,comp.lang.c++ Date: 1997-11-05T00:00:00+00:00 List-Id: In article , wrote: >kaz@helios.crest.nt.com (Kaz Kylheku) writes: > >> >> In article <345F49A2.5F5DC5A0@aom.ericsson.se>, >> Ted Lyngmo wrote: >> >Bob Horvath wrote: >> >> >> >> Hmmmm. How big is an int? >> > >> >As I've understood it, an int has two legal sizes. A short has only one, >> >> You haven't understood it. >> >> A short is large enough to represent numbers in the range -32767 to >> 32767. An int is also large enough to represent numbers in the >> same range. A long can represent numbers in the range -2147483647 >> to +2147483647. > >Nor have you. The definitions are as follows. > >short <= int <= long >short < long >short > char Where in the ISO standard did you dig up this definition? I can't find it. >If your system does not conform to this, it isn't ISO (I thinhk it was ISO) >compliant. Actually there are embedded systems in which every integral type, including char, has the same size (namely 1, of course). Trivia time: hosted implementations of C require character types to be smaller than the type int. Why? Because the getc() and putc() functions require the type int to be able to represent every possible unsigned char value, _and_ the special value EOF to indicate end of input. The embedded implementation in which every integral type is one byte wide (32 bit byte, mind you) can't support these functions. Thus your little table is wrong. It should be: char <= short <= int <= long with the aditional requirement to make a hosted implementation possible: char < int >What you stated above is true for (I would assume) all 32bit systems. It >will not necessarily hold for 64 bit or 128 bit systems. No. What I stated is in the C standard, so it's true for all conforming implementations. It defines the minimum ranges that all arithmetic types must have. I wasn't making any claim about the relative sizes of the integral types, just repeating the minimum range requirements. -- "In My Egotistical Opinion, most people's C programs should be indented six feet downward and covered with dirt." -- Blair P. Houghton