www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1998/07/25/04:01:59

From: Tim DOT Writer AT ftlsol DOT com (Timothy Writer)
Subject: Re: long long vs long
25 Jul 1998 04:01:59 -0700 :
Message-ID: <m34sw7m7kp.fsf.cygnus.gnu-win32@snoopy.ftlsol.com>
References: <_Michael_H._Warfield_'s_message_of__Wed,_22_Jul_1998_11:08:42_-0400_(EDT)_>
Mime-Version: 1.0 (generated by tm-edit 7.108)
To: Larry Hall <lhall AT rfk DOT com>
Cc: "Michael H. Warfield" <mhw AT alcove DOT wittsend DOT com>,
GMurray AT cware DOT co DOT uk (Graham Murray), gnu-win32 AT cygnus DOT com

Larry Hall <lhall AT rfk DOT com> writes:

> At 01:48 PM 7/23/98 -0400, Timothy Writer wrote:
> >Furthermore, in section 6.1.2.5 the Standard states, "There are four signed
> >integer types, designated as signed char, short int, int, and long int."  It
> >then goes on to say, "In the list of signed integer types above, the range of 
> >values of each type is a subrange of the values of the next type in the
> >list."
> >
> >In other words,
> >
> >    sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)
> >
> >and
> >
> >    sizeof(char)  == 1
> >    sizeof(short) >= 2
> >    sizeof(int)   >= 2
> >    sizeof(long)  >= 4
> >
> 
> Sorry but this doesn't seem to follow.  I agree with the interpretation of
> the standard, namely:
> 
>   sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)
> 
> However, this does NOT imply what follows (the sizeof lines after the "and".)
> The implication from the standard is:
> 
>   sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long)
> 
> AND
> 
>   sizeof(char)  == 1
>   sizeof(short) >= 1
>   sizeof(int)   >= 1
>   sizeof(long)  >= 1
> 
> which someone on this list pointed out previously.  I think the key words 
> here are that "the range of values of each type is a subrange of the values 
> of the next type in the list."  Are we getting a little too far off topic 
> for this list?

This follows from the earlier section of the standard I posted which states
the minimum ranges for each type, namely -127 to +127 for signed char, -32767
to +32767 for signed short, etc.  These imply that char is at least 8 bits,
short is at least 16 bits, and int and long are at least 32 bits.  Assuming a
char is exacly eight bits (it's not clear to me whether the standard requires
that or not) it follows that:

    sizeof(char)  == 1
    sizeof(short) >= 2
    sizeof(int)   >= 2
    sizeof(long)  >= 4

As to whether we're getting off topic.  Clearly this group is about
portability and I was disturbed by the number of misinformed posters
spreading incorrect information about something so fundamental to porability.

-- 
Tim Writer                                              Tim DOT Writer AT ftlsol DOT com
FTL Solutions Inc.
Toronto, Ontario, CANADA
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019