range of char

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wolfgang Jeltsch

    range of char

    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
  • WW

    #2
    Re: range of char

    Wolfgang Jeltsch wrote:[color=blue]
    > 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?[/color]

    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


    Comment

    • Buster

      #3
      Re: range of char

      "Wolfgang Jeltsch" <jeltsch@tu-cottbus.de> wrote
      [color=blue]
      > 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?[/color]

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

      Regards,
      Buster.


      Comment

      • tom_usenet

        #4
        Re: range of char

        On Fri, 03 Oct 2003 19:28:07 +0200, Wolfgang Jeltsch
        <jeltsch@tu-cottbus.de> wrote:
        [color=blue]
        >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?[/color]

        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

        Comment

        • Ron Natalie

          #5
          Re: range of char


          "Wolfgang Jeltsch" <jeltsch@tu-cottbus.de> wrote in message news:blkbau$d26 44$1@ID-77306.news.uni-berlin.de...[color=blue]
          > 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?[/color]

          Absoltutely not. unsigned char has to do at least 0...255, but char can
          either be signed or unsigned.


          Comment

          Working...