Re: short int always 16 bits or not?

Discussion in 'C Programming' started by Barry Schwarz, Apr 20, 2013.

  1. On Fri, 19 Apr 2013 17:14:26 -0700 (PDT), 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?


    You need to go to page 33 and read the last sentence that introduces
    the table on page 34.

    >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)


    In what way? Since both the value of the type and the size of the
    type are determined by the particular implementation, why would they
    be inconsistent? What would be inconsistent is using the values from
    one implementation on a different one.

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


    Because the real world is not limited to your imagination. (There are
    even character encoding schemes other than ASCII.)

    Yes.

    --
    Remove del for email
    Barry Schwarz, Apr 20, 2013
    #1
    1. Advertising

  2. In article <>,
    Gordon Burditt <> wrote:
    >
    >Old (obsolete) systems include the PDP-8, with 12 bit wide memory
    >and registers, and the GE-635 which used 36-bit-wide memory where
    >characters were either 6 or 9 bits, selectable by a bit in a tally
    >word (which now might be called a "fat pointer")...


    And the PDP-10 which packed five 7-bit characters into a 36-bit word.

    And don't get started on the sixbit and radix-50 alphabets used
    by the pdp-10 and pdp-11 respectively.

    --
    -Ed Falk,
    http://thespamdiaries.blogspot.com/
    Edward A. Falk, Apr 22, 2013
    #2
    1. Advertising

  3. Edward A. Falk <> wrote:
    > In article <>,
    > Gordon Burditt <> wrote:


    >>Old (obsolete) systems include the PDP-8, with 12 bit wide memory
    >>and registers, and the GE-635 which used 36-bit-wide memory where
    >>characters were either 6 or 9 bits, selectable by a bit in a tally
    >>word (which now might be called a "fat pointer")...


    > And the PDP-10 which packed five 7-bit characters into a 36-bit word.


    > And don't get started on the sixbit and radix-50 alphabets used
    > by the pdp-10 and pdp-11 respectively.


    I used to write programs in PDP-10 Fortran that would read 9 track
    tapes with EBCDIC data and convert to ASCII. I believe it reads four
    tape bytes into a 36 bit word.

    There is also a way to write 36 bit words to tape, and read them back
    again, which I believe writes two words to nine tape bytes.

    But yes, the normal ASCII form for PDP-10 data files stores five
    characters per word, with one bit left over. Line oriented editors
    would write five digit line numbers in the first word of the line,
    with the low bit set. Compilers would recognize those, ignore the number
    as far as program input went, but use the number in error messages.

    It would confuse TECO users, though, if you sent them line numbered
    files.

    -- glen
    glen herrmannsfeldt, Apr 22, 2013
    #3
    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. Eric Sosman

    Re: short int always 16 bits or not?

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

    Re: short int always 16 bits or not?

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

    Re: short int always 16 bits or not?

    James Kuyper, Apr 20, 2013, in forum: C Programming
    Replies:
    2
    Views:
    179
    James Kuyper
    Apr 22, 2013
  4. Les Cargill

    Re: short int always 16 bits or not?

    Les Cargill, Apr 20, 2013, in forum: C Programming
    Replies:
    0
    Views:
    180
    Les Cargill
    Apr 20, 2013
  5. Keith Thompson

    Re: short int always 16 bits or not?

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

Share This Page