I have an int of 3483498. When I cast it a char, it displays the char 'j'. When I convert back, it is 20. The ASCII for 20 is not even 'j'. I am utterly lost. How do I get back 3483498?
1 2 3 4 5
int D = 3483498;
char a = char(D);
cout << a << endl;
int b = int(a);
cout << b << endl;
That's odd, I tried it and got 106, which is what it should be.
How do I get back 3483498?
You can't go back once you cast a type like int to a type that is smaller. You lose the rest of in the important bits.
It's like rounding a decimal to the nearest integer. If I gave you a number that I rounded beforehand, you wouldn't be able to tell me (for sure) what the tenths place was.