range of char

Discussion in 'C++' started by Wolfgang Jeltsch, Oct 3, 2003.

  1. Hello,

    what does the ANSI C++ standard say about the minimal range of the char
    type? Is it guaranteed that char contains at least the numbers from 0 to
    255?

    Thanks a lot.

    Wolfgang
    Wolfgang Jeltsch, Oct 3, 2003
    #1
    1. Advertising

  2. Wolfgang Jeltsch

    WW Guest

    Wolfgang Jeltsch wrote:
    > Hello,
    >
    > what does the ANSI C++ standard say about the minimal range of the
    > char type? Is it guaranteed that char contains at least the numbers
    > from 0 to 255?


    Nope. It is implementation defined if char is signed or not. And yes, it
    is guaranteed to have at least 8 bits, and all of its bits must be used in
    the value representation.

    --
    WW aka Attila
    WW, Oct 3, 2003
    #2
    1. Advertising

  3. Wolfgang Jeltsch

    Buster Guest

    "Wolfgang Jeltsch" <> wrote

    > what does the ANSI C++ standard say about the minimal range of the char
    > type? Is it guaranteed that char contains at least the numbers from 0 to
    > 255?


    The C++ standard ISO/IEC 14882:1998 is available from the ISO online
    shop, http://www.iso.ch/iso/en/prods-services/ISOstore/store.html, for
    US$18, and worth every penny.

    Regards,
    Buster.
    Buster, Oct 3, 2003
    #3
  4. Wolfgang Jeltsch

    tom_usenet Guest

    On Fri, 03 Oct 2003 19:28:07 +0200, Wolfgang Jeltsch
    <> wrote:

    >Hello,
    >
    >what does the ANSI C++ standard say about the minimal range of the char
    >type? Is it guaranteed that char contains at least the numbers from 0 to
    >255?


    On many platforms, including IIRC MSVC++, it has the range [-128, 127]
    - remember, it can represent the same values as either signed or
    unsigned char. However, unsigned char does have at least that range,
    since it much have 8-bits or more, and every bit pattern must
    represent a unique number (due to the modulo arithmetic rules).

    Tom
    tom_usenet, Oct 3, 2003
    #4
  5. Wolfgang Jeltsch

    Ron Natalie Guest

    "Wolfgang Jeltsch" <> wrote in message news:blkbau$d2644$-berlin.de...
    > Hello,
    >
    > what does the ANSI C++ standard say about the minimal range of the char
    > type? Is it guaranteed that char contains at least the numbers from 0 to
    > 255?


    Absoltutely not. unsigned char has to do at least 0...255, but char can
    either be signed or unsigned.
    Ron Natalie, Oct 3, 2003
    #5
    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. wwj
    Replies:
    7
    Views:
    549
  2. wwj
    Replies:
    24
    Views:
    2,507
    Mike Wahler
    Nov 7, 2003
  3. Ben Pfaff
    Replies:
    5
    Views:
    473
    Tristan Miller
    Jan 17, 2004
  4. lovecreatesbeauty
    Replies:
    1
    Views:
    1,043
    Ian Collins
    May 9, 2006
  5. Replies:
    2
    Views:
    293
Loading...

Share This Page