Thread: char type and bits

  1. #16
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Quote Originally Posted by QuantumPete View Post
    I should have said "treat these" instead of "decodes these". Sorry about the confusion!

    QuantumPete
    But it doesn't. The implisit conversion will sign extend the char to an int when char is passed as a single arguement.

    String and character literal escapes must be spesified as unsigned octal or hex, but that has nothing to do with printf.

    Printing functions don't care about the sign of a character, because they just map each set of eight bits to a symbol. Signed or unsigned these bits still have the same mapping.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by King Mir View Post
    But it doesn't. The implisit conversion will sign extend the char to an int when char is passed as a single arguement.
    But then the corresponding %c argument is converted to unsigned char after being converted to int.
    Quote Originally Posted by C89 draft 4.9.6.1
    c The int argument is converted to an unsigned char , and the resulting character is written.
    Last edited by robwhit; 09-10-2008 at 07:32 PM.

  3. #18
    Registered User
    Join Date
    Apr 2006
    Posts
    2,149
    Hm. Well if the standard says that then I guess it's true. But its odd that they specify that considering that it makes no difference what so ever, except perhaps that code pages are commonly listed as unsigned values.
    It is too clear and so it is hard to see.
    A dunce once searched for fire with a lighted lantern.
    Had he known what fire was,
    He could have cooked his rice much sooner.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 11-23-2007, 01:48 PM
  2. Playing card data structure?
    By crypticgeek in forum C++ Programming
    Replies: 10
    Last Post: 12-31-2006, 05:29 PM
  3. Script errors - bool unrecognized and struct issues
    By ulillillia in forum Windows Programming
    Replies: 10
    Last Post: 12-18-2006, 04:44 AM
  4. Replies: 10
    Last Post: 06-26-2005, 11:27 AM
  5. Cross platform portability, about data types...
    By gaah in forum C++ Programming
    Replies: 9
    Last Post: 01-21-2005, 10:32 PM