r/ProgrammerHumor • • Oct 04 '26

Meme architectureDependentChars

Post image
3.0k Upvotes

372 comments sorted by

View all comments

Show parent comment

5

u/NotQuiteLoona Oct 04 '26 edited Oct 05 '26

char is 8 bits because memory is addressed in 8 bits, and 7 bits would be... Awkward. And this bit was in the end used for parity checks, and later for extended encodings.

3

u/Ma8e Oct 05 '26 edited Oct 05 '26

Historically it has been all over the place. Depending on the hardware, it could was anything between 1 and 48 bits.

Edit: never mind. The above is about bytes, not chars.

2

u/tracernz Oct 05 '26

Minimum 8 bits, but not required to be 8 bits.

1

u/Ma8e Oct 05 '26

Na, it could be as low as one bit, and 7 was not uncommon for a while.

3

u/-suspended- Oct 05 '26

The definition for a char in C/C++ is 8 bits minimum.

1

u/Clen23 Oct 05 '26

no shit sherlock that's what the post is about.

u/NotQuiteLoona is talking about how memory is addressed, not how long a char is.

-1

u/tracernz Oct 05 '26

Those two things are the same thing in ISO C (it defines sizeof(char) = 1).

2

u/tracernz Oct 05 '26

No, the standard requires a minimum of 8 bits.

2

u/Ma8e Oct 05 '26

Which standard?

3

u/tracernz Oct 05 '26

ISO C.

0

u/Ma8e Oct 05 '26

And that is the only standard in existence? My point is that you can't take for granted that everything is ISO, or even C.

1

u/tracernz Oct 05 '26

The question at the top of this sub thread was about C. Very few environments exist these days that don’t conform to the basics of ISO C like this though if you want to generalise. I personally haven’t ever come across one.