I have char variables in TTree, which are just small integers and I normally type cast them into integers after reading in from the tree. I wonder if I can do arithmetic without type casting and save some memory/CPU ?
I hear that C/C++ always does operations on shorts or chars by type casting to integers first. Is it true ?
char a = 1;
cout << a << endl; // gives you nothing
As far as cout is concerned (and this is C++) a char is an ASCII character. So if you were to do
char a = 's';
cout << a << endl; // gives you nothing
this would print an ‘s’.
cout << int(a) << endl;
is the proper syntax and does incur an real performance penalty (that I know of).
[quote]in this respect it would be nice to have new data type for 1 byte integer, say, Mini_t
[/quote]If you make it works in a reasonable way, please let us know.
[quote]whenever I use case …
[/quote]I do not see this problem