What are UChar_t, wchar,UInt_t... ?

I know "u" means "unsigned".
But why does C++ have these types?
what for?
when to use these more various types?
Couldn't we just stick with: int, char unsigned int, char, double?

Thank you,
L
Wide chars are for Unicode, which has more bytes per letter than ascii which is for American English but insufficient for many other languages.

you need a variety of sized numeric types to use a space efficiently. If all you need are some integers from 0-100 to represent grades in school, for example, you don't need 64 bits each for that and if you have thousands of students in dozens of classes each over years... its a lot of wasted space for nothing. Use 1 byte and save 7 each time! This is huge over networks, databases and other places where wasted space hurts performance and costs money for big-data work. Its also critical in games and real time systems where bigger = slower, more often than not.

for historic reasons C++ has a ton of redundant types. In the old days, everyone knew these weird names like word, long, long long, short, etc. Then computer hardware doubled, and doubled again, and is on the verge of doubling again (128 bit registers exist on many machines now, and will soon be the norm). What we gonna call that, a long long long? An extra long long? It was becoming silly. So they renamed them. Then C renamed them (and has the best names of the lot, of the form signed/unsigned type num bytes like uint32_t, int64_t. Then I think C++ renamed them again. And then Microsoft and other vendors renamed them and added to them (Microsoft has all sorts of junk like void* is "handle", __int64, and more weirdness).

I think they are slowly, very very slowly, converging on an agreeable set of names. Maybe in c++ 14 or c++ 21. But today, there are about 100 redundant types, maybe more, all to represent 10 integers and 2 floats.

Thank you for the explanation, very comprehensive.
Topic archived. No new replies allowed.