Java Reference
In-Depth Information
76543210
High-order bit
(HOB)
Low-order bit
(LOB)
Figure3-2BitNumbering
Charactersandsymbolsarestoredincomputersaccordingtoacodein
whicheachcharacterorsymbolcorrespondstoanumericvalue.Forex-
ample,ifweagreethattheupper-caseletterAisrepresentedbythenum-
ber1,theletterBbythenumber2,andsoforth,thentheupper-caseletter
Zisrepresentedbythenumber26.Onceweacceptthisschemeforrepre-
sentinglettersbynumbers,wecanencodetextmessagesusingnumbers
insteadofletters.Inthismanner,thelettersACZwouldberepresentedby
thenumbers1,3,26.
Severalschemesforrepresentingcharacterdatahavebeenadopted
andabandonedovertheyears.HollerithcodeandtheExtendedBinary
CodedDecimalInterchangeCode,knownasEBCDIC,werepopularsome
timeago.AmericanStandardCodeforInformationInterchange,orASCII
(pronouncedas-key),hasgainedalmostuniversalacceptance.Javarec-
ognizesseveralcharactersets,includingASCII;however,thelanguage
supportsauniversalcharactersetnamedUnicode.WhileASCIIcharac-
tersarestoredin8-bits,Unicodeisbasedon16-bitvalues.Thiswiderfor-
matallowssupportingnon-Englishandmultilingualenvironments. Figure
3-3 (onthenextpage)showsthesymbolsintheASCIIcharactersetas
wellastheirdecimalandhexadecimalvalues.
Youcanuse Figure3-3 todeterminethedecimalandhexvalueofany
ASCIIsymbol.First,youlookupthecolumnvalueofthesymbol,and
thenaddtoittherowvalue.Forexample,thedecimalASCIIcodeforthe
letter“c”is96plus3,or99.Bythesametoken,thevalueoftheASCII
symbolforthenumber“6”is36hexadecimalor54decimal.
Charactersarestoredincomputermemoryaccordingtothenumeric
valuesassignedtothemintheadoptedrepresentation.InASCIIencoding
thename“Jane”appearsincomputermemoryasthedecimalvalues74,
97,110,and101sincethesearetheASCIIdecimalvaluesfortheletters
“J”,“a”,“n”,and“e.”InHex,thevalueswouldbe4A,61,6E,and65. Figure
3-4 showsthebinaryandhexvaluesfortheASCIIcharactersthatform
the name “Jane.”
 
Search WWH ::




Custom Search