Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #384174

Re: remark on defining size of basic types

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c
Subject Re: remark on defining size of basic types
Date 2024-04-04 22:22 -0700
Organization None to speak of
Message-ID <87zfu8idtc.fsf@nosuchdomain.example.com> (permalink)
References (4 earlier) <uum354$1l27$1@i2pn2.org> <uum95f$lr8o$1@dont-email.me> <uumiu8$o78i$1@dont-email.me> <20240404200454.00003811@yahoo.com> <uunvah$15vot$1@dont-email.me>

Show all headers | View raw


James Kuyper <jameskuyper@alumni.caltech.edu> writes:
> On 4/4/24 13:04, Michael S wrote:
>> On Thu, 4 Apr 2024 12:02:16 -0400
>> James Kuyper <jameskuyper@alumni.caltech.edu> wrote:
>> 
>>> On 4/4/24 09:15, Janis Papanagnou wrote:
>>> ...
>>>> Since I remember C had always just defined a '<=' (or '>=') relation
>>>> between the unsized basic integral data types.  
> ...
>> He meant sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long
>> long)
>
> That's not actually the case. In the above, you are not using <= as the
> C operator, but simply to indicate relative order over multiple items; I
> will do the same. What is specified is equivalent to the following
>
> LONGLONG_MIN <= LONG_MIN <= INT_MIN <= SHORT_MIN <= SCHAR_MAX
> SCHAR_MAX <= SHORT_MAX <= INT_MAX <= LONG_MAX <= LONGLONG_MAX
> UCHAR_MAX <= USHORT_MAX <= UINT_MAX <= ULONG_MAX <= ULONGLONG_MAX
>
> SCHAR_MAX <= UCHAR_MAX
> INT_MAX <= UINT_MAX
> LONG_MAX <= ULONG_MAX
> LONGLONG_MAX <= ULONGLONG_MAX

SHRT, not SHORT.
LLONG, not LONGLONG.

> The sizes are not required to be in the same order as the maximum
> values, nor in the opposite order of the minimum values. If they were in
> a different order, it would imply a lot of padding bits, which would be
> very odd, but not prohibited.

For completeness, the way it's described in the standard (quoting N3220
6.2.5p10-11) is :

    For any two integer types with the same signedness and different
    integer conversion rank (see 6.3.1.1), the range of values of the
    type with smaller integer conversion rank is a subrange of the
    values of the other type.

    The range of nonnegative values of a signed integer type is a
    subrange of the corresponding unsigned integer type, and the
    representation of the same value in each type is the same.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Medtronic
void Void(void) { Void(); } /* The recursive call of the void */

Back to comp.lang.c | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

remark on defining size of basic types fir <fir@grunge.pl> - 2024-04-04 01:34 +0200
  Re: remark on defining size of basic types Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-04-04 00:15 +0000
    Re: remark on defining size of basic types fir <fir@grunge.pl> - 2024-04-04 03:46 +0200
      Re: remark on defining size of basic types Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-04-04 02:44 +0000
        Re: remark on defining size of basic types fir <fir@grunge.pl> - 2024-04-04 13:32 +0200
          Re: remark on defining size of basic types Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-04-04 15:15 +0200
            Re: remark on defining size of basic types James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-04-04 12:02 -0400
              Re: remark on defining size of basic types Michael S <already5chosen@yahoo.com> - 2024-04-04 20:04 +0300
                Re: remark on defining size of basic types Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-04-04 13:10 -0700
                Re: remark on defining size of basic types Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-04-05 02:04 +0200
                Re: remark on defining size of basic types James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-04-05 00:43 -0400
                Re: remark on defining size of basic types James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-04-04 19:39 -0400
                Re: remark on defining size of basic types Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-04-04 22:22 -0700
            Re: remark on defining size of basic types Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-04-04 23:38 +0000
              Re: remark on defining size of basic types Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-04-05 02:25 +0200
                Re: remark on defining size of basic types Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-04-05 00:46 +0000
                Re: remark on defining size of basic types Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-04-05 08:30 +0200
                Re: remark on defining size of basic types Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-04-05 07:18 +0000
                Re: remark on defining size of basic types Michael S <already5chosen@yahoo.com> - 2024-04-05 17:19 +0300
                Re: remark on defining size of basic types Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-04-05 08:07 -0700
              Re: remark on defining size of basic types gazelle@shell.xmission.com (Kenny McCormack) - 2024-04-05 02:56 +0000

csiph-web