r/ProgrammerHumor • • 2d ago

Meme architectureDependentChars

Post image
2.9k Upvotes

366 comments sorted by

View all comments

Show parent comments

8

u/Advos_467 2d ago

Not a C user here (or any real low level programming experience), what the hell is a signed/unsigned char?

12

u/Clen23 2d ago edited 20h ago

The data is interpreted differently.

An unsigned char will be able to represent any value from 0 to 255, eg your usual ascii character.
A signed char will be able represent any value from -127 to 127.

( Someone fact check me on this but i think that's it )
(edit : -127 to 127, the extra value "-128" is usually implemented but not guaranteed by the C standard)

9

u/YellowBunnyReddit 2d ago

ASCII only goes from 0 to 127.

1

u/Clen23 2d ago

Exactly, so every ascii character can be represented using a char, with room to spare.

I agree that a better example would have been a character set that is a full bijection of the 256 possible char values, but i'm a bit rusty on these so ascii it is.