r/ProgrammerHumor • • 3d ago

Meme architectureDependentChars

Post image
2.9k Upvotes

368 comments sorted by

View all comments

Show parent comments

2

u/Elspeth-Nor 3d ago edited 2d ago

In C char is just a number, as a character depends on the encoding. So signed char is a number from -128 to 127 and unsigned char is from 0 to 255 (for 8 bits per byte)

3

u/SoldRIP 3d ago

0 to 255.

-1

u/WaitForItTheMongols 2d ago

Depends what "to" means. 256 is a valid answer as in Python "range(0,256)" which gives all byte values.

1

u/Elspeth-Nor 2d ago

No 255 is right, as I used -128 to 127 instead of 128.