Article View: comp.lang.c.moderated
Article #1981Re: Why Use 'Int' Instead of 'Long'? (With today's compilers)
From: Tanmoy Bhattacharya
Date: Thu, 15 Feb 1996 13:57
Date: Thu, 15 Feb 1996 13:57
38 lines
2524 bytes
2524 bytes
In article <4fu84r$9f9@solutions.solon.com> Mongkok
<jyetse@undergrad.math.uwaterloo.ca> writes:
<snip>
The size of pointers varies from machine to machine, but the
size of an int is defined in ANSI to be at least 2 chars. And
the size of long int must be strictly bigger than short int,
and must be bigger than or equal to int.
All these statements are wrong!
First, sizeof (int) is allowed to be 1 ... all that ANSI says is that
int should be at least 16 bits. It says char is at least 8 bits: it
does not say that it cannot be more. All types have to occupy an
integral number of chars, though all bits may not necessarily be used
in representing the value of the object. All bits in a char are
however significant.
All values representable as a signed char must be representable as a
short as well. All values representable as a short must be
representable as an int. Likewise, all values representable as an int
must be representable as longs. longs must be at least 32 bits. signed
and unsigned integral types must take the same amount of storage, and
represent the positive numbers identically, and they follow a similar
hierarchy. char must behave identically to either signed char or
unsigned char except for its type. Without unused bits, all
this implies sizeof(long) >= sizeof(int) >= sizeof(short) >=
sizeof(char) == 1. So, if you left out the `strictly', you would have
been `reasonably correct'.
Cheers
Tanmoy
--
tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
<http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
Technical Details
Message-ID:
<4fve4g$dm8@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4fjk00$nss@solutions.solon.com> <4fjp0k$p6m@solutions.solon.com> <4fp1o2$h99@solutions.solon.com> <4fu84r$9f9@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: tanmoy@qcd.Lanl.GOV (Tanmoy Bhattacharya) Newsgroups: comp.lang.c.moderated Subject: Re: Why Use 'Int' Instead of 'Long'? (With today's compilers) Date: 15 Feb 1996 07:57:36 -0600 Organization: Los Alamos National Laboratory Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4fve4g$dm8@solutions.solon.com> References: <4fjk00$nss@solutions.solon.com> <4fjp0k$p6m@solutions.solon.com> <4fp1o2$h99@solutions.solon.com> <4fu84r$9f9@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com