Theoretically, if I were to subtract the number 10 from the ASCII character 10 (which is really 00110001 00110000), what would I get?
Does the computer add both ASCII characters and subtract?
Asked By : CodyBugstein
Answered By : vonbrand
If you subtract the integer 10 from the ASCII character (code) for 'a' (which is decimal 61) you get the ASCII code for 'Q'.
If you are asking because of mysteriously looking expressions like c - 'a'
(or c - '0'
) (some C hacks are fond of those), they give the letter position of c
(respectively the value of the digit c
). Used for interesting stuff like c - 'A' + 'a'
(uppercase to lowercase), or to translate a decimal ASCII string to integer:
p = string; s = 0; for(p = string; *p; p++) s = 10 * s + *p - '0';
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/9377
0 comments:
Post a Comment
Let us know your responses and feedback