• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

problem in understanding operations between chars

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 23958
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
It was the best of times. It was the worst of times. It was a tiny ad.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic