Re: short int always 16 bits or not?

Discussion in 'C Programming' started by Les Cargill, Apr 20, 2013.

  1. Les Cargill

    Les Cargill Guest

    Shriramana Sharma wrote:
    > Hello. I am reading the C99 standard as available from:
    > http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf
    >
    > I note that it specifies (on p 34) macros defining the minimum and
    > maximum values of a short int corresponding to a size of 16 bits.
    > However it doesn't explicitly say that short int-s should be of 16
    > bits size. So can I trust short int-s to be 16 bits size or not?
    >


    No, not really. You have to verify this. This being said,
    it's true for a vast majority of platforms.

    > Also, doesn't prescribing #define-s for integer type min/max values
    > conflict with the general (?) understanding that the size of these
    > types are implementation defined? I mean, is the general
    > understanding wrong? (For instance see:
    > http://en.wikipedia.org/wiki/Short_integer#cnote_b_grp_notesc)
    >


    Supposedly, said macros would be adapted to be platform specific.

    > Finally, why would anyone want char to be other than 8 bits? *Is*
    > char on any platform *not* 8 bits?
    >


    We can't say in general. It's a heck of a founding assumption
    to give up, so hopefully there's a good reason.

    > Thanks.
    >


    --
    Les Cargill
    Les Cargill, Apr 20, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Barry Schwarz

    Re: short int always 16 bits or not?

    Barry Schwarz, Apr 20, 2013, in forum: C Programming
    Replies:
    2
    Views:
    201
    glen herrmannsfeldt
    Apr 22, 2013
  2. Eric Sosman

    Re: short int always 16 bits or not?

    Eric Sosman, Apr 20, 2013, in forum: C Programming
    Replies:
    0
    Views:
    201
    Eric Sosman
    Apr 20, 2013
  3. Shriramana Sharma

    Re: short int always 16 bits or not?

    Shriramana Sharma, Apr 20, 2013, in forum: C Programming
    Replies:
    10
    Views:
    317
    Ken Brody
    Apr 25, 2013
  4. James Kuyper

    Re: short int always 16 bits or not?

    James Kuyper, Apr 20, 2013, in forum: C Programming
    Replies:
    2
    Views:
    184
    James Kuyper
    Apr 22, 2013
  5. Keith Thompson

    Re: short int always 16 bits or not?

    Keith Thompson, Apr 20, 2013, in forum: C Programming
    Replies:
    0
    Views:
    192
    Keith Thompson
    Apr 20, 2013
Loading...

Share This Page