• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in understanding operations between chars

 
M Mistroni
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i m going thru scjp 1.5 exams, i have produced a class that was mentioned in a question
here it is:


here's the output
Comparing:Good vs Bad
a-o=26
Comparing:Good vs Ugly
g-o=32
Comparing:Bad vs Ugly
g-a=37
UglyBadGood----
Ugly
a
o

i can't figure out why 'a' - 'o' will produce 26.. where does that number come from?

anyone could help?

thanks and regards
marco
 
Henry Wong
author
Marshal
Pie
Posts: 21023
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i can't figure out why 'a' - 'o' will produce 26.. where does that number come from?


The number is the difference between the unicode for 'a' and the unicode for 'G'. Note that you formula for the value is different than what you showed on the left of the equals.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic