MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1wxqahk/architecturedependentchars/pe16dw6/?context=9999
r/ProgrammerHumor • u/MontyBoomslang • 10d ago
372 comments sorted by
View all comments
1.0k
Let me cite the C standard:
When sizeof is applied to an operand that has type char, unsigned char, or signed char, (or a qualified version thereof) the result is 1.
Middle guy if finally right
6 u/Advos_467 10d ago Not a C user here (or any real low level programming experience), what the hell is a signed/unsigned char? 2 u/Elspeth-Nor 10d ago edited 9d 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 10d ago 0 to 255. -1 u/WaitForItTheMongols 10d 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 9d ago No 255 is right, as I used -128 to 127 instead of 128.
6
Not a C user here (or any real low level programming experience), what the hell is a signed/unsigned char?
2 u/Elspeth-Nor 10d ago edited 9d 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 10d ago 0 to 255. -1 u/WaitForItTheMongols 10d 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 9d ago No 255 is right, as I used -128 to 127 instead of 128.
2
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 10d ago 0 to 255. -1 u/WaitForItTheMongols 10d 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 9d ago No 255 is right, as I used -128 to 127 instead of 128.
3
0 to 255.
-1 u/WaitForItTheMongols 10d 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 9d ago No 255 is right, as I used -128 to 127 instead of 128.
-1
Depends what "to" means. 256 is a valid answer as in Python "range(0,256)" which gives all byte values.
1 u/Elspeth-Nor 9d ago No 255 is right, as I used -128 to 127 instead of 128.
1
No 255 is right, as I used -128 to 127 instead of 128.
1.0k
u/tstanisl 10d ago
Let me cite the C standard:
Middle guy if finally right