Padding bits and char, unsigned char, signed char

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ioannis Vranos

    Padding bits and char, unsigned char, signed char

    Under C95:

    Is it guaranteed that char, unsigned char, signed char have no padding bits?
  • CBFalconer

    #2
    Re: Padding bits and char, unsigned char, signed char

    Ioannis Vranos wrote:
    >
    Under C95: Is it guaranteed that char, unsigned char, signed
    char have no padding bits?
    unsigned char, yes. The others by implication. I haven't checked
    the standard. Why don't you?

    --
    [mail]: Chuck F (cbfalconer at maineline dot net)
    [page]: <http://cbfalconer.home .att.net>
    Try the download section.



    --
    Posted via a free Usenet account from http://www.teranews.com

    Comment

    • Harald van =?UTF-8?b?RMSzaw==?=

      #3
      Re: Padding bits and char, unsigned char, signed char

      On Fri, 28 Mar 2008 16:01:54 -0500, CBFalconer wrote:
      Ioannis Vranos wrote:
      >Under C95: Is it guaranteed that char, unsigned char, signed char have
      >no padding bits?
      Just a note: padding bits are a concept introduced in the standard in
      C99; C90/C95 left much more unspecified about the representation of
      integer types.
      unsigned char, yes.
      Where is this guarantee made? In C99, 5.2.4.2.1 makes it as clear as it
      can: "The value UCHAR_MAX shall equal 2^CHAR_BIT - 1." I don't have a
      copy of an older standard. Does it make the same guarantee?
      The others by implication.
      How so? What's preventing a signed integer type and its corresponding
      unsigned type from having a different number of padding bits?

      Comment

      • pete

        #4
        Re: Padding bits and char, unsigned char, signed char

        Harald van =?UTF-8?b?RMSzaw==?= wrote:
        >
        On Fri, 28 Mar 2008 16:01:54 -0500, CBFalconer wrote:
        Ioannis Vranos wrote:
        Under C95: Is it guaranteed that char,
        unsigned char, signed char have no padding bits?
        >
        Just a note: padding bits are a concept introduced in the standard in
        C99; C90/C95 left much more unspecified about the representation of
        integer types.
        >
        unsigned char, yes.
        >
        Where is this guarantee made?
        In C99, 5.2.4.2.1 makes it as clear as it
        can: "The value UCHAR_MAX shall equal 2^CHAR_BIT - 1." I don't have a
        copy of an older standard. Does it make the same guarantee?
        It doesn't.
        There's really nothing about padding in the "basic types" in C90.
        The others by implication.
        >
        How so? What's preventing a signed integer type and its corresponding
        unsigned type from having a different number of padding bits?
        I think he meant char and signed char, but even then I disagree.

        As far as I know, signed char can have padding bits.

        --
        pete

        Comment

        • Ben Bacarisse

          #5
          Re: Padding bits and char, unsigned char, signed char

          Harald van Dijk <truedfx@gmail. comwrites:
          On Fri, 28 Mar 2008 16:01:54 -0500, CBFalconer wrote:
          >Ioannis Vranos wrote:
          >>Under C95: Is it guaranteed that char, unsigned char, signed char have
          >>no padding bits?
          >
          Just a note: padding bits are a concept introduced in the standard in
          C99; C90/C95 left much more unspecified about the representation of
          integer types.
          >
          >unsigned char, yes.
          >
          Where is this guarantee made? In C99, 5.2.4.2.1 makes it as clear as it
          can: "The value UCHAR_MAX shall equal 2^CHAR_BIT - 1."
          But that alone is not enough, is it? The clearest statement comes
          later in 6.2.6. p1: "For unsigned integer types other than unsigned
          char, the bits of the object representation shall be divided into two
          groups: value bits and padding bits (there need not be any of the
          latter).". So, unsigned char has only value bits.

          --
          Ben.

          Comment

          Working...