When doing character arithmetic is it a rule that you perform the calculations in base 10 or base 8? My book says 'A' = 101 in base 8 or 65 base 10 but when I insert the character values in base 8 into an example my book gives about illustrating this point i get some funny results. The code below is an example in my book for a Ceaser Cipher that tries to find the new character. If I try to convert 'Y' and shift 8 spots to find a new character and if ch = 'Y' and n = 8 I'm expecting to get character 'G'.
ch = (char)('A' + (Character.toUpperCase(ch) - 'A' + n) % 26);
the math works out to
65 + (89 - 65 + 8) % 26 = 71 (base 10)
101 + (131 - 101 + 8) % 26 = 113 (base 8)
If i convert the 71 (base 10) back into base 8, I'll get 107 which is character 'G' which is the correct character. My question is why I can't perform character arithmetic in base 8? 113 is character 'K' which is the wrong character. Is the rule when doing character arithmetic to convert all the values into base 10 and then convert them back into base 8?