|
|
Log in / Subscribe / Register

Would you like signs with those chars?

Would you like signs with those chars?

Posted Oct 24, 2022 21:29 UTC (Mon) by mb (subscriber, #50428)
In reply to: Would you like signs with those chars? by mss
Parent article: Would you like signs with those chars?

>will print fffffffe if char is signed but just (intuitively expected) fe if it is unsigned.

Well, char in case of signed is consistent with short (always signed).

short c = 0xffff;
printf ("%x\n", c - 1);

prints fffffffe.

Therefore, char = unsigned char actually is inconsistent.


The LWN site is currently under high scraper load, so comment display has been suppressed for anonymous users. If you are a human, you may read the comments by clicking the button below:

Note: you can avoid this step in the future by logging into your LWN account.


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds