View Single Post
Old 07-18-2016, 11:24 PM   #9
Soundwave-
Carry your failures proud
FFR Veteran
 
Soundwave-'s Avatar
 
Join Date: Sep 2015
Age: 23
Posts: 644
Default Re: programming question

Once upon a time, we had 16 bit computers.

Things were simply then. We had bytes, and we had integers.

That was it.

But then, the 32 bit age came along.

Now we have a problem. We have two types of integers, along with a byte: 16 bit and 32 bit. So we decided to call one of them "long", and one of them "short". We also came up with the general keyword "int".

This has made a lot of people very angry and been widely regarded as a bad move.

See, this "int" usually means "long", so that if somebody wanted an integer they didn't get a "short" when they expected a "long"; there's little harm in expecting a "short" and getting a "long". But sometimes, you'll get a "short" when you want a "long", because nobody *really* said what "int" was supposed to mean. Sometimes this even happens today (although you can pretty much count on getting a "long" these days).

Then we got to the new age of 64 bit. This age became so prevalent that 32 bit computers had to at least be able to handle 64 bit data.

We needed something long. Really long. Like longer than a long. So we came up with the "long long". That's for real a data type. But this is where things get really bad. See, a lot of people don't know about the "long long". They think the "long" is longer than the "int", and as long as the "long long". But more often than an "int" is a "short", a "long" is an "int". Which can be dangerous if you're expecting a "long long" from your "long" which is really an "int".

If you're confused. It's okay. There's literally nothing too important in the above paragraphs.

But I'm coming to a conclusion here.

It's about "short". See, "short" is really cool. "short" is small enough that you can fit two of them in a single computer register, but big enough that you can have a number for virtually every single character in text in any language imaginable.

People don't use "short" as a number very often anymore. It's not very useful. So we renamed "short", to "char", and decided to use it for characters.

"char" is literally a number as much as "int" is. Not even in the sense that you can assign numbers to characters. You can do that. No, this is in the sense that "char" acts like a number any every known way. It just *also* acts like a character, because we decided that's useful.



So you can replace "int" with "char" and expect everything to work.

Sort of. Input is a bitch.

I haven't found any information concerning how streams work with characters. I'm willing to bet "not well" is the answer.

Consider reading in single character strings. You should then just be able to do mystring[0] to get a character.
__________________
Quote:
Originally Posted by [11:38 PM] Hakulyte
only person who can legit tilt me is like YoshL
Quote:
Originally Posted by スンファンさん
右に3回回らない限り間違います。

Last edited by Soundwave-; 07-18-2016 at 11:40 PM..
Soundwave- is offline   Reply With Quote