Showing posts with label signed. Show all posts
Showing posts with label signed. Show all posts

Wednesday, April 3, 2013

char





More on the char Type

  • Usually 8 bits, one byte.
  • Represented as a small integer (short)
  • If it is an integer, and it is signed (7 bits plus a sign bit) which means we have 27 -1 = 127 as the largest integer stored 01111111, or
    11111111 = -128 = -27 when it is signed
  • Characters are represented via an ASCII encoding which is a positive integer corresponding to each character. This implies that if characters are stored assigned, we can accommodate 127 characters.

Unsigned Characters

  • If the internal representation of characters is unsigned, that is, stored as an unsigned short integer, then we have available to us 28 -1 = 255 characters.
  • C does not specify how they are stored. Often they are stored as an unsigned short integer.

Type qualifiers