Article View: comp.lang.c.moderated
Article #2031Re: Why Use `Int` Instead
From: Martin Ambuhl
Date: Fri, 16 Feb 1996 15:28
Date: Fri, 16 Feb 1996 15:28
43 lines
1898 bytes
1898 bytes
sthuang@hns.com (Steven Huang) in <4g1793$muh@solutions.solon.com>
wrote:
>You're way off track as well. Short or long has nothing to do with
>the size of the integer in terms of bits. You will never be guaranteed
>a certain number of bits you can use. If I remember correctly the
>only guarantee you have is that short is less than or equal to int,
>and int is less than or equal to long.
The above is true only in the senses that (1) that the machine need not
have `bits' at all, and (2) there is no _maximum_ size for these types.
The standard requires that the implementation behave as if certain
things were true:
type bits min max
char >= 8 * * (same as either unsigned
signed " <=-127 >=127 or signed type)
unsigned " >=255
short <=-32767 >=32767
unsigned " >=65535
int (see short)
long <=-2147483647
>= 2147483647
unsigned " >= 4294967295
It is very difficult to implement these limits on a binary machine
unless
char >= 8 bits (mandated)
short >= 16 bits
int >= 16 bits
long >= 32 bits
If, for example, sizeof(char) == sizeof(long), then a char would need to
be implemented as if it had 32 bits.
--
* Martin Ambuhl net: mambuhl@ripco.com
* Chicago, IL (USA)
Technical Details
Message-ID:
<4g27qr$qce@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: mambuhl@ripco.com (Martin Ambuhl) Newsgroups: comp.lang.c.moderated Subject: Re: Why Use `Int` Instead Date: 16 Feb 1996 09:28:27 -0600 Organization: Ripco Communications, Inc. Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4g27qr$qce@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com