A Tutorial On Data Representation - Integers, Floating-Point Numbers, and Characters
A Tutorial On Data Representation - Integers, Floating-Point Numbers, and Characters
A Tutorial on Representation
Data
1 N mb r ytms . u e Ss e
1 D c l ae 0 N mb r ytm . ei ( s 1 ) u e Ss 1 ma B e 1 B ay B s 2 N mb r ytm . i r (ae ) u e Ss 2 n e 1 H xd c l ae 6 N mb r ytm . ea ei ( s 1 ) u e Ss 3 ma B e 1 C n es nf m H xd c loB ay . o vro r 4 i o ea ei t i r ma n 1 C n es nf m B ay oH xd c l . o vro r 5 i o i r t ea ei n ma 1 C n es nf m B s r t D c l ae 0 . o vro r 6 i o ae o ei ( s 1 ) ma B 1 C n es nf m D c l ae 0 t B s . o vro r 7 i o ei ( s 1 )o ae ma B 1 Eec e (u e Ss ms o vro ) . xrssN mb r yt C n es n 8 i e i
H ma b i sue decimal (ae 1 )a d duodecimal (ae 1 )n mb r u n eg s n bs 0 n bs 2 u e ss mso cu t ga dmesrme t (rb b b cue e ae 0f g r yt fr o ni n e n aue nspo a l ea s w h v 1 i es y n a dt ob te) o ues s binary (ae ) u e ss m, s h yae n w i o s C mp tr ue g . b s 2 n mb r yt a te r e ma ef m b ayd i lo o e t ( o na t nios o eai i t o d r o i r it cmp n ns k w s r s tr p rt g n w n ga n a s ) n s ts o a dof ncmp t g w a ouehexadecimal (ae1 ) r t e - n n f I o ui , e l s a . n s b s 6 o octal 4 F ai -on N mb r e rsnain . l t gP i u e R pee tt o n t o (ae ) u e ss msa a b s 8 n mb r yt ,s compact fr fre rsn b ay u es e om o rpee t i r n mb r n . 4 I E7 43 -iS g -rc i F ai -o . E -5 2b i l Peio l t gP 1 E tne sn o n 4 Eec e (o t gp i N mb r . xrssF ai -o t u es 2 i l n n ) 1.1 Decimal (Base 10) Number System 4 I E7 46 -iD u l Peio F ai . E -5 4b o b -rc i l t gP 3 E t e sn o n 4 Moe nF ai -o t e rsnai . 4 r o l t gP i R pee tt n o n n o D c l u e ss m h s e smb l 0 1 2 3 4 5 6 7 8 a d9 cld ei n mb r yt ma e a tn y o : , , , , , , , , , n ,ae s l
3 n-iU s n dItg r . b ni e ne es 1 t g 3 S n dItg r . i e ne es 2 g 3 n-iS nItg r i S nMa n u e e r . b i ne esn i - g i d R pe 3 tg g t 3 n-iS nItg r i 1 C mp me t e r . b i ne esn ' o l n R pe 4 tg s e 3 n-iS nItg r i 2 C mp me t e r . b i ne esn ' o l n R pe 5 tg s e 3 C mp tr ue 'C mp me t e rsna . o ues s 2 o l n R pee t 6 s e 3 R n e f b 2 C mp me t i e Itg . a g o n-i ' o l n S n d ne 7 t s e g 3 D cd g2 C mp me t u es . eo i ' o l n N mb r 8 n s e 3 Eec e Itg r e rsnai ) . xrs ( e e R pee tt n 9 i n o
. h rc E c dn e g digits I ue positional notation. h ti tel s s n i n d i (g t 5 C aatr no i .t ss T a s h e t i i a t it r h, a -g f c g i 5 7b A CI o e aa SA CI S / C6 6 . -i S IC d ( U - S I I I 4 1 t k ,O E mot itio teod r f 0 0(n s r n s tescn r h- s d i s d i s fh re o 1 ^ u i o o e) h eo d i t g) t , g mot it g 5 8b Lt - ( a S / C8 5 -) . -i ai 1 a I I 8 91 2 t n k O E io teod r f 0 1( n)te h dr h- s d iio te re o 1 ^ s fh re o 1 ^ t s h ti i t e , r g mot its fh od r f 0 2 g 5 O h r -iEtni o U - S I(S IEt . te 8b x s n f SA CIA CI x 3 t e o (u de s a ds o .o ea l h n rd) n o n F r xmp , , e 5 U i d ( a S / C1 6 6U i r l h r . n o e a I I 0 4 n es C aa 4 c k O E v a 75=71^ +31^ +51^ 3 02 01 00 5 U F8(n o e rnfr t nF r t 8 . T- U i d Ta s mai oma - 5 c o o 5 U F1 (n o e rnfr t nF r t 1 . T-6 U i d Ta s mai oma 6 c o o We h l e oe d c l u e wt a o t n luf Di mb u y re. sa d n t a ei n mb r i n pi asf l ma h o i f i i ai s x a gt s 5 U F3 (n o e rnfr t nF r t 3 . T-2 U i d Ta s mai oma 7 c o o 5 F r t o Mu i ye e . n o e Tx F . omas f l B t (g U i d ) et i 8 t ., c l 1.2 Binary (Base 2) Number System 5 F r t o Tx Fe . omas f et is 9 l 5 0 Wi o sC . 1 n w ' MDC d p g d o eae B ay n mb rss m h st o smb l 0 a d 1 cld bits. ti a o a i r u e yt n e a w y o : n , ae s l I s l s 5 1 C i s C aatr es . 1 h ee h rc St n e positional notation, r xmp , f ea l o e 5 2 C lt gSq e csfr a k gC aatr . 1 oai e u ne ( R n i h rc ln o n e 110 =124+023+122+121+020 01B ^ ^ ^ ^ ^ 5 3 F raa rga . o Jv Po rmmes j v . i . h r 1 r- a a n o C a s
We sa d n t a b ay n mb r wt a sf B S me po rmmi h l e oe l ir u e i n h uf . o i x rga n g l g a e d n t b ayn mb r wt pex b(g 0 1 0 0 0, r rf b a u g s e oe i r u es i rf 0 e . b 0 1 0 )o pex n n h i ., i wt te i q oe (g b 1 0 1 1 '. i h b s u td e . ' 0 0 1 1 ) h t ., Ab ay its ae a i r d iicld bit.i t i iclda n g l E h b ss ae byte (h 8b u i Po a l g t l w y -i n ? rb b t t y 5 5 Dsl i H x a e & H x d os . 1 i a n e Vl s pyg u e Ei r t 6 Eec e (aa e rsnai ) . xrssD t R pee tt n 1 i o
1/25
www3.ntu.edu.sg/home/ehchua/programming/java/DataRepresentation.html
4/7/12
b cue = 3. ea s 8 2 )
We h l e oe h xd c l u e ( soth xwt a uf H S mepo rmmi l g a e d n t h x u es sa d n t a ea ei n mb ri h r e) i sf .o l ma n , h i x rga n a u g s e oe e n mb r g n wt pex x(g 0 1 3 5 ) r rf xwt h x it u td(g x C A D 8 '. i rf 0 e . x A C F, pex i e d iq oe e . ' 3 4 9 B ) h i ., o i h g ., Ec h xd c l its l cldahex digit. s po rmmi l g a e acp l ecs ' 't ' 'a w la ah ea ei d iia o ae ma g s l Mot rga n a u g s ce to r e a o f s e s g n w a l u p r s ' 't ' ' p ec e A o F . a C mp tr ue b ayss m i te i en l p rt n, ste aeb i f m b ayd i l l t n cmp n ns o ues ss i r yt n h i n ra o eai sa h y r utr n e r t o l o i r it e c o i o o e t n ga e r c . H w vrw i go ra i al gsq e c o b ay i icmb r me n err rn . ea ei lytm iue o ee, ri r ed g o e u ne f i r b ss u es t n n n n t o a d r - o e H xd c op ma ss e s sd aa s compact fr o shorthand fr i r b sEc h x its q i l t o4b ayb si. h r a dfr b sa om r o b ay i. ah e d iie u a n t n t g ve i r i,e sot n o 4 i, s n t ., h t flw : oo s l 0 (00) H 00B (D 0) 4 (10) H 00B (D 4) 8 (00) H 10B (D 8) C (10) H 10B (2) 1D 1 (01) H 00B (D 1) 5 (11) H 00B (D 5) 9 (01) H 10B (D 9) D (11) H 10B (3) 1D 2 (00) H 01B (D 2) 6 (10) H 01B (D 6) A (00) H 11B (0) 1D E (10) H 11B (4) 1D 3 (01) H 01B (D 3) 7 (11) H 01B (D 7) B (01) H 11B (1) 1D F (11) H 11B (5) 1D
4/7/12
T cnet21 t hxdcml o ovr 6D o eaeia: 211 qoin=6rmidr5 6/6 utet1 eane= 1/6 qoin= rmidr0 61 utet1 eane= 11 /6 qoin= rmidr1(utet0so) utet0 eane= qoin= tp Hne 21 =15 ec, 6D 0H
4/7/12
fr l e a ds a hlflw d omu td n t i t oo e . a rg y l O c y ud c e o ted t rpee tt nsh me cr i cnt i s i p rcl ,h peio a drn ewl e ne o ei d n h aa e rsnai ce , et n o s a t n atu rte rc i n a g ib d o a rn , i a sn l i oe . e c, ii otn t u d r a ddata representation t w i correct a dhigh-performance po rms mp sd H nei smp r to n es n t a t o re t n rga .
3. Integer Representation
Itg r aewhole numbers o fixed-point numbers wt terd p i fixed a e tel s s n i n b . h yae ne es r r i h ai o t h x n f r h e t i i at i Te r t a -g f c t cnrs t real numbers o floating-point numbers, h r tep si o terd p i vr sIii otn t tk o t to a r w ee h oi n fh a i o t ai .tsmp r t o ae t o x n e a n t ta i e esa df ai -o t u es r t ae d f e t i cmp tr T e h v d f e t e rsnai oe h tn g r n l t gp i n mb r ae r td i rnl n o ues h y ae i rn rpee tt n t o n n e f e y . f e o a dae rcse d f e t (g f ai -o t u es r poesdi a ocldf ai -o t rcso) l t g n r poesd i rnl e .l t gp i n mb r ae rcse n s-ae l t gp i poesr F ai f e y .,o n n l o n n .o n p i n mb r wl e i usdl e. o t u es ib d cse a r n l s t C mp tr ue fixed number of bits t rpee t ni e e.h cmmo l ue b - n tso i e es r 8b , 6 o ues s a o e rsn a n g rT e o t n -sd il gh frn g r ae -i 1 y te t t b , 2b o 6 -i B s e b - n tstee r t orpee tt nsh me frne es i 3 -i r 4b . ei s il gh,h r ae w e rsnai ce so i g r t t t d te o t : 1 Unsigned Integers:a rpee t eoa dp si i e es . cn e rsn zr n oi en g r t v t . 2 Signed Integers: a rpee tzr, oi e a d n g t e i e es T re rpee tt n sh me h d b e . cn e rsn eo p si n e ai n g r he e rsnai ce s a en t v v t . o po oe fr i e i e es rp sd o s n d n g r g t : a S nMa n u e e rsnai . i - g i d rpee tt n g t o b 1 C mp me te rsnai . ' o l n rpee tt n s e o c 2 C mp me te rsnai . ' o l n rpee tt n s e o Y u a tepo rmme, edt d c eo teb - n t a drpee tt nsh mefr o rne esd p n i o o , s h rga rn e o ei n h il gh n e rsnai ce d te o o yu i gr eed g n t , n y u a pct n rq i me t S p oeta y un e acu tro cu t gas l u ni f m 0u t 2 0 y u o r p lai ' e u e ns u p s h t o ed o ne fr o ni i os r . n ma q a ty r l t o p o 0 ,o mi t h oe h 8b u s n di e e sh me s h r in n g t e u esn o e . g co s te -i ni e n g r ce a tees o e ai n mb r i l d h t g t v vv
4/7/12
n
8 1 6 3 2 6 4
Mnmm iiu
0 0 0 0
Mxmm aiu
(^)1 (25 28=5) (^6- (6,3) 21)1 =555 (^2- (4249725 (+dgt) 23)1 =,9,6,9) 9 iis (^4- (1,4,4,7,0,5,1) 26)1 =8467403795165 (9 dgt) 1+ iis
4/7/12
H netene e i+ D e c,h i g rs 0 t
T e rw ak o s nma n u e e rsnai ae h da b cs fi - g i d rpee tt n r: g t o 1 T ee r t orpee tt n (0 0 0 0 Ba d1 0 0 0 B frh n mb r eo w i cu l dt i f i c . h r ae w e rsnai s0 0 0 0 n 0 0 0 0 )o te u e zr, h h o l e o n f e y o c d a ei n c a dcnui . n o fs n o 2 P si a dn g t ene es edt b poesdsp rtl . oi e n e ai i g r n e o e rcse e aae . t v v t y
4/7/12
H netene e i+ D e c,h i g rs 0 t
A a ,h da b cs r: g i te rw ak ae n 1 T ee r t orpee tt n (0 0 0 0 Ba d1 1 1 1 B fr eo . h r ae w e rsnai s0 0 0 0 n 1 1 1 1 )o zr. o 2 T e oi ene es n n g t ene es edt b poesdsp rtl . h p si i g r a d e ai i g r n e o e rcse e aae . t v t v t y
4/7/12
7D(K 0 O)
4/7/12
-5 =6D+(5)=6D D 5 -D 0
6D 5 -D 5 00 00B 10 01 11 11B+ 11 01( 01 10B 01 10
B cue fh fixed precision ( . ea s o te i, . fixed number of bits)a n-i2 cmp me t i e i e e h s cr i rn e F r e , n b ' o l n s n d n g r a a et n a g . o t s e g t a ea l fr = ,h rn eo 2 cmp me t i e i e ess 1 8t + 2 . ui a d i ( dsbrco )ii xmp ,o n 8 te a g f ' o l n s n d n g r i- 2 o 1 7 D r g d i n a u t t n, s e s e g t n t o n ai t i otn t cek h te te eu ece s h rn ei oh r od, h te overflow o underflow h s curd mp r to h c w eh rh rsl xed ti a g , te w rsw eh r a t s n r a ocr . e
-2D(rn) 17 wog
+2D(rn) 16 wog
T eflwn d ga ep i h w te2 cmp me t ok. yr-r n i ten mb ri , a e f m - 2 t h oo i i rm xln o h ' o l n w rsB ear g g h u e le vl s r l g a as s e a n n u o 18 o + 2 ae e rsne cni o s b i oi te ar b . 1 7 r rpee td o t u ul yg r g h cr i g y n n y t
mnmm iiu
mxmm aiu
9/25
www3.ntu.edu.sg/home/ehchua/programming/java/DataRepresentation.html
4/7/12
+27- (+2) (^)1 =17 +21)1(+277 (^5- =3,6) +23)1(+,4,8,4)9 (^1- =2174367(+ dgt) iis +26)1 (^3-
Answers
1 T ern eo u s n d n-i i e esi [ , 2 ( - ) . h rn eo n-i 2 cmp me ts n d i e e i . h a g f ni e g b n gr s 0 t t ^ n 1 ] Te ag f b ' o l n i e n grs t s e g t [2(-) +^n1-] -^n1, 2(-)1; 2 8 ( 1 1 1 0 )0 ( 0 0 0 0 )1 ( 0 0 0 0 )1 7 ( 1 1 1 1 )2 5 ( 1 1 1 1 ) . 8 0 0 0 0 , 0 0 0 0 , 0 0 0 1 ,2 0 1 1 1 ,5 1 1 1 1 . 3 +8 (11 10)-8 (00 10)- (11 11)0 (00 00) + (00 00) -2 (00 . 8 00 00,8 11 00,1 11 11, 00 00, 1 00 01, 18 10 0 0 )+ 2 ( 1 1 1 1 ) 0 0 ,1 7 0 1 1 1 . 4 + 8 ( 1 1 1 0 )- 8 ( 1 1 1 0 )- ( 0 0 0 0 )0 ( 0 0 0 0 o 1 0 0 0 )+ ( 0 0 0 0 ) . 8 0 0 0 0 ,8 1 0 0 0 ,1 1 0 0 1 , 0 0 0 0 r 0 0 0 0 ,1 0 0 0 1 , - 2 ( 1 1 1 1 )+ 2 ( 1 1 1 1 ) 1 7 1 1 1 1 ,1 7 0 1 1 1 . 5 + 8 ( 1 1 1 0 )- 8 ( 0 0 0 1 )- ( 1 1 1 1 )0 ( 0 0 0 0 o 1 1 1 1 )+ ( 0 0 0 0 ) . 8 0 0 0 0 ,8 1 1 1 1 ,1 1 1 1 0 , 0 0 0 0 r 1 1 1 1 ,1 0 0 0 1 , - 2 ( 0 0 0 0 )+ 2 ( 1 1 1 1 ) 1 7 1 0 0 0 ,1 7 0 1 1 1 .
4/7/12
w l s eo a i s ae : e a zr,sl t td l l r u
A f ai -o t u e i tp ayepesdi tesi ti n tt n wt afraction ()a d a exponent () f l t gp i n mb r s y i l xrse n h c ni oai , i o n n cl e f c o h F, n n Eoa cr i radix ()i tefr o F r E D c l u es s rd o 1 ( 0 E; heb ayn mb r uerd o 2 et n a r, h om f ^ . ei n mb r ue a i f 0 F 1 ^ )w i i r u es s a i f n ma x l n x ( ^ ) F 2 E. R pee tt n o f ai p i n mb ri n tu i e F rea l te n mb r5 . 6 cn b rpee td a e rsnai o f l t g o t u e s o n u . o xmp , h u e 5 6 a e e rsne s o n n q e 5 5 6 1 ^ , . 5 6 1 ^ , . 5 6 0 3 a ds o . h f co a p r cnb normalized.nten r le fr . 6 0 1 0 5 6 0 2 0 0 5 6 1 ^ , n o n T e r t n l at a e ai I h omazd om, i tees n a i ln nzr d ib fr te a ip i .o ea l d c l u e 1 3 4 6 cnb n r le a h r io l s g o -eo it e e h rd o tF r xmp , ei n mb r 2 . 5 7 a e omazd s y ne g o x n e ma i 1 2 4 6 0 2 b ay u e 1 1 . 0 1 cnb n r le a 1 0 1 1 B 2 3 . 3 5 7 1 ^ ; i r n mb r 0 0 1 1 B a e omazd s . 1 0 1 ^ . n i Iii otn t n t ta f ai -o t u es uf f m loss of precision w e rpee tdwt a i dn mb r f tsmp r to oe h tl t gp i n mb r sf rr a o n n e o h n e rsne i fe u e o h x b s e . 2b o 6 -i.h ib cueteeaeinfinite n mb r fel u es ee wti as l a g o sy i (g 3 -i r 4b ) i s ea s h r r t ., t tT s u e o ra n mb r ( n i n ma rn e f as v h l 0 t 0 )O teoh r a d a b b ay atr cnrpee t finite 2 nd t c n mb r H ne n t l h ra . o . . n h te h n , n-i i r p t n a e rsn a 0 1 t n e ^ ii t u es e c, o a te el sn . l n mb r cnb rpee td T e ers a poi t nwl e sdi ta ,eu e i l s f cuay u es a e e rsne .h n aet p rx i ib ue n ed rsl d n o o acrc. ma o l s t s Iia oi otn t n t ta f ai n mb r rh t ivr muhl s f i t h ni e e ai mei Icu b ts l mp r to oe h tl t g u e ai mei s ey c e e ie ta n g r rh t. o l e s a o n t c s f n c t t ct d sedu wt a ocldd d ae floating-point co-processor. e c, s i e esf o r p lai d e n t e u e p e p i s-ae e i td h l c H neue n g r iy u a pct n o s o rq i t i o r f ai -o t u es l t gp i n mb r o n n . I cmp tr f ai -o t u es r rpee tdi si tin tt no fraction () n exponent () i a n o ues l t gp i n mb r ae e rsne n c ni oai f ,o n n e f c o F ad E wt radix o h f 2 i te om o F 2 E B t Ea dFcnb p si a w l s e ai . d r cmp tr a o tEE 5 s n adfr , h fr f ^ . oh n n a e oi e s e a n g t eMo en o ues d p I 7 4 t d r o t v l v E a rpee t gf ai -o t u esT eeaet orpee tt nsh me: 2b s g -rc i a d6 -id u l e rsni l t gp i n mb r h r r w e rsnai ce s 3 -i i l peio n 4b o b n o n n . o tne sn t e peio . rc i sn
Normalized Form
Lt i s ae i a ea l sp oe h t h 3 -ip t r i1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 , e' l t t wt n xmp ,u p s ta te 2b at n s sl r u h e t e 00 01 1 00 00 00 00 00 wt: i h S=1
www3.ntu.edu.sg/home/ehchua/programming/java/DataRepresentation.html 11/25
4/7/12
E=10 00 00 01 F=0100 00 00 00 00 1 00 00 00 00 00 I te n h normalized form,h ataf co in r le wt a i lil d g1i te om o 1 F I tiea l te te c l at n s omazd i n mpc e i u r i i h it a n n h fr f . . h xmp ,h n s e ataf co i1 0 1 0 0 0 0 0 0 0 0 0 0 = 1 + 1 2 - + 1 2 - = 1 3 5 . c l at n s . 1 0 0 0 0 0 0 0 0 0 0 u r i ^2 ^3 .7D T es nb rpee t tes no ten mb rwt S 0fr oi ea dS 1fr e ai n mb rI tiea l wt h i i e rsns h i fh u e, i = o p si n = o n g t e u e. h xmp i g t g h t v v n s e h S 1 tiia e ai n mb ri. 1 3 5 . = ,h s n g t e u e,e - . 7 D s v ., I n r le fr teata ep n n i E 1 7 ( -ae ecs-2 o b s1 7. h i b cue w n e t n omazd om, h c l xo e t s - 2 s cld xes1 7 r i -2 ) T i s ea s e ed o i u o l a s rpee t ohp si a dn g t eep n n. t a 8b E rn i f m 0t 2 5 teecs-2 sh mecu e rsn b t oi e n e ai xo e tWi n -i ,a g g r t v v h t n o o 5 ,h xes1 7 ce ol d po i ataep n n o -2 t 1 8 I tiea l E 1 7 1 9 1 7 2 . rv e c lxo e t f1 7 o 2 . h xmp , - 2 = 2 - 2 = D d u n s e H nete u e rpee tdi- . 7 ^ = 5 5 . e c,h n mb re rsne s 1 3 5 2 2 - . D
De-Normalized Form
N r le fr h s sr u po l wt a i lil d g1fr h f co , cn o rpee t h n mb r eo omazd om a a ei s rb m, i n mpc e i i o e h it a n o te r t n i a n t e rsn te u e zr! ai t C n i e o r l nti o v c y us f h ! n eo s D -omazdfr w s ei dt rpee t eoa doh r u es en r le om a d v e o e rsn zr n te n mb r i s . F r = ,h n mb r aei ted -omazdfr A i lil d g0( s a o 1 iue fr h f co ;n te o E 0 te u es r n h en r le om. n mpc e i i it a n i t d f )s sd o te r t n a d h ne ai ataep n n ia as 1 6 H nete u e zr cnb rpee tdwt E 0a dF 0(ea s 0 0 2 - 2 = ) c lxo e ts l y - 2 . e c,h n mb r eo a e e rsne i = n = b cue . ^ 1 6 0. u w h Wecna orpee t eys l oi ea dn g t en mb r i d -omazdfr wt E 0 F r xmp , S 1 a l e rsn vr ma p si n e ai u esn en r le om i = . o ea l i = , s l t v v i h ef E 0 a dF 0 1 0 0 0 0 0 0 0 0 0 0 .h ataf co i0 0 1 1 2 - + ^ 3 0 3 5 . i e = , i = , n = 1 0 0 0 0 0 0 0 0 0 0 T e c l at n s . 1 = ^ 2 1 2 - = . 7 D S c S 1 i s u r i n t an g t en mb rWi E 0 teata ep n n i - 2 . e c ten mb rs- . 7 ^ 1 6 = - . 0 - 9 e ai u e. t = ,h c l xo e ts 1 6 H ne h u e i 0 3 5 2 - 2 v h u 441^3, w i ia et me s l e ai n mb rc s t zr) h h s n x e l ma n g t e u e (oe o eo. c r y l v l
Summary
I smmayte a e N icl l e a flw : nu r,h vl () a u td soo s u s ca l F r E 2 4 N = ( 1 ^ 1 F 2 ( - 2 ) T een mb r aei tes-ae normalized fr T e o1 5, -)S . ^ E 1 7 .h s u es r n h ocld l om. h s nb rpee t tes n o ten mb rFat n l at(. ) r n r le wt a i li l d g 1 T e i -i e rsns h i f h u e. rco a p r 1 F ae omazd i n mpc e i . h g t g i i h it a n ep n n ib so i ecs) f 2 ,oa t rpee t ohp si a dn g t eep n n.h rn eo ep n n xo e ts i (rn xeso 1 7 s s o e rsn b t oi e n e ai xo e tT e a g f xo e t a t v v i- 2 t + 2 . s 16 o 17 F r = 0 N = ( 1 ^ 0 F 2 ( 1 6 . h s n mb r aei tes-ae denormalized fr T e oE , -)S . ^ - 2 ) T ee u es r n h ocld l om. h ep n n o 2 - 2 ea ae t a ey ma n mb rD n r le fr in e e t rpee t eo(i F 0a d xo e t f ^ 1 6 vl ts o vr s l u e. e omazd om s ed d o e rsn zr wt = n u l i h E 0. cna orpee t vr s l oi e n n g t e u e c s t zr. = ) t a l e rsns ey ma p si a d e ai n mb r l e o eo I s l t v v o F r = 2 5 irpee t sei vl ssc a N (oi e n n g t enit) n N N(o a u e) h i oE 5 , e rsns p c la e,uh s I F p si a d e ai i n y a d a n t n mb r T i s t a u t v v fi . s b y n te cp o tiatl eo d h so e fh rc . s ie
4/7/12
Hints:
1 Lret oi e u e: = , = 1 1 1 1 ( 5 ) F 1 1 1 1 1 1 1 1 1 1 1 1 . . ag s p si n mb rS 0 E 1 1 1 0 2 4 , = 1 1 1 1 1 1 1 1 1 1 1 t v S ls p si n mb rS 0 E 0 0 0 0 1 ( ) F 0 0 0 0 0 0 0 0 0 0 0 0 . maet oi e u e: = , = 0 0 0 0 1 , = 0 0 0 0 0 0 0 0 0 0 0 l t v 2 Sme s b v, u S 1 . a a a o eb t = . 3 Lret oi e u e: = , = , = 1 1 1 1 1 1 1 1 1 1 1 . . ag s p si n mb rS 0 E 0 F 1 1 1 1 1 1 1 1 1 1 1 1 t v S ls p si n mb rS 0 E 0 F 0 0 0 0 0 0 0 0 0 0 0 0 . maet oi e u e: = , = , = 0 0 0 0 0 0 0 0 0 0 1 l t v 4 Sme s b v, u S 1 . a a a o eb t = .
www3.ntu.edu.sg/home/ehchua/programming/java/DataRepresentation.html
13/25
4/7/12
T e a e N icl l e a flw : h vl () a u td soo s u s ca l N r le fr F r E 2 4 , N = ( 1 ^ 1 F 2 ( - 0 3 . omazd om:o 1 i 06 -)S . ^E12) D n r le fr F r = 0 N = ( 1 ^ 0 F 2 ( 1 2 ) T ee r i te e omazdfr e omazd om:o E i , -)S . ^ - 0 2 .h s aen h d n r le om. i F r = 2 4 , rpee t sei vl ssc a N ( f i ) a (o a u e) oE 0 7 N e rsns p c la e,uh s I F i it , N n t n mb r a u nn y N .
Peiin rcso
Snl ige
www3.ntu.edu.sg/home/ehchua/programming/java/DataRepresentation.html
4/7/12
Dul obe
01 00 00 00H 00 00 00 00 Nmn =10 2-02 (i) .B ^12 (225788021 .20355704 1^38 0-0)
7E FF FF FFH FF FF FF FF Nmx =11.1 212 =( (a) ...B ^03 2 -2-2 212 ^5) ^03 (177914635 1^0) .96338217 038
Peiin rcso
Snl ige
Dul obe
00 00 00 00H 00 00 00 01 Dmn =00.12-02=1 (i) ... ^12 2-22-02=2-04 ^5 ^12 ^17 (491^34 . 0-2)
01 FF FF FFH 0F FF FF FF Dmx =01.12-02= (a) ... ^12 (-^5)2-02 12-2^12 (440477142 .51710403 1^38 0-0)
Special Values
Zero: eocn o b rpee tdi ten r le fr a dmut erpee tdi d n r le fr wt E 0a d Z r a n t e e rsne n h omazd om, n i s b e rsne n e omazd om i = n i h F 0 T ee r t orpee tt n fr eo + wt S 0a d- wt S 1 = .h r ae w e rsnai so zr: 0 i = n 0 i = . o h h Infinity: h vl o +nit (g 1 0 a d- f i (g - / ) r rpee tdwt a ep n n o a 1 ( = 2 5 T e a e f i n y e . / ) n i it e . 1 0 ae e rsne i n xo e t f l ' E u f i ., n n y ., h ls 5 fr i l peio a dE = 2 4 fr o b -rc i ) = ,n S 0( r I F a dS 1( r I F. o s g -rc i n ne sn 0 7 o d u l peio , 0 a d = f + N ) n = f - N ) e sn F o o Not a Number (NaN): a d n tsavl ta cn o b rpee tda ra n mb r e . / )N Ni rpee td N N e oe a e h t a n t e e rsne s el u e (g 0 0. a s e rsne u .
www3.ntu.edu.sg/home/ehchua/programming/java/DataRepresentation.html 15/25
4/7/12
5. Character Encoding
I cmp trme r, h rc r r "no e "(r" pee td) s g acoe " aatre cd g sh me"( a n o ue moy caat ae e cd d o r rsne " ui e e n h sn c rc h e no i ce s a n k " aatr e"" ast " aatr p, rcd p g " c rc st c r " c rc ma "o " e a e) h e , h e, h e o . F r xmp , A CIa w l s ai , n o ea dma y te caatr es o ea l i S I( e a Lt 1 U i d ,n en s l n c n oh r h rc st : e ) cd n mb r 6 D ( 1 )t 9 D ( A )rpee t ' 't ' ' rset e . o e u es 5 4 H o 0 5 H e rsns A o Z ,ep cvl i y cd n mb r 9 D ( 1 )t 1 2 ( A )rpee t ' 't ' ' rset e . o e u es 7 6 H o 2 D 7 H e rsns a o z ,ep cvl i y cd n mb r 4 D ( 0 )t 5 D ( 9 )rpee t ' 't ' ' rset e . o e u es 8 3 H o 7 3 H e rsns 0 o 9 ,ep cvl i y Iii otn t n t ta terpee tt nsh memut ek o nb fr ab ayp t r cnb i epee . ., tsmp r t o oe h t h e rsnai ce a o s b n w e e i r at n a e n rrtd E . o n e t g te -ip t r "1 0 0 1 B cu rpee t n ti u d rh snk o no lt te esne cd di h 8b at n 0 0 0 0 " o l e rsn a yh g n e te u n w n o h p r t e d n y o no e t . T emot o h s cmmo l ue caatr no i sh me ae 7b A CII / C6 6 a d8b Lt - ( O I 8 5 -) n -sd h rc e cd g ce s r: -i S I( O I 4 ) n -i ai xI / C 8 9x y e n t S E t n S E fr etr e rp a caatr a dU i d ( O I 1 6 6 frnen t n lai ( 8 ) o w s n uo en h rc s n n o e I / C 0 4 )o i rai azt n i n. e e, c S E t o i o 1 A7b e cd gsh me( c a A CIcnrpee t 2 caatr a dsmb l A 8b caatr no i sh me -i no i ce t n s h s S I a e rsn 1 8 h rc s n y o . n -i h rc e cd g ce u ) e s t e n ( c a Lt -)a rpee t 5 caatr a dsmb l w ees 1 -ie cd gsh me sc a U i d U S2 s h s ai xcn e rsn 2 6 h rc s n y o ; h ra a 6b no i ce ( h s n o e C -) u n e s t n u c cnrpee t 6 , 6caatr a dsmb l a e rsns 5 3 h rc s n y o . 5 e s
5.1 7-bit ASCII Code (aka US-ASCII, ISO/IEC 646, ITU-T T.50)
A CIA ra Sa d r C d frnomai Itr a g ) o e fh er r h rc r o i sh me. S I(mei n tn ad o e o Ifr t n nec n e i n o te al caat cd g ce s c o h s i e e n A CIi oin l a 7b cd .I h sb e etn e t 8b t b t rui e te 8b cmp trme r SI s ri l g ay -i o e t a en x d d o -i o et tz h -i o ue t e t e l i t moy og n ai . h 8hb w s r i l ue fr ra i t n ( e t-i a oin l sd o parity check i te alcmp tr) z o T t g ay n h er o ues y . C d n mb r 3 D ( 0 )t 1 6 ( E )ae r tb (i l a l caatr a tb l e : o e u es 2 2 H o 2 D 7 H r pi a l d p yb )h rc s s a u td n e sa e e a
Hx e 2 3 4 5 6 7
0
S P 0 @ P ` p
1
! 1 A Q a q
2
" 2 B R b r
3
# 3 C S c s
4
$ 4 D T d t
5
% 5 E U e u
6
& 6 F V f v
7
' 7 G W g w
8
( 8 H X h x
9
) 9 I Y i y
A
* : J Z j z
B
+ ; K [ k {
C
, < L \ l |
D
= M ] m }
E
. > N ^ n ~
F
/ ? O _ o
C d n mb r 2 ( 0 )ite o e u e 3 D 2 H s h blank o space caatr r h rc . e ' 't ' ' 3 H 3 H ( 0 1 0 0 B t 0 1 1 0 B o ( 0 1 x x Bw ee x xitee u a n i e e 0 o 9 : 0 - 9 0 1 0 1 o 0 1 0 1 ) r 0 1 x x h r x x s h q i l tn g r ve t vl ) ae u ' 't ' ' 4 H 5 H ( 1 1 0 0 B t 0 0 1 1 B o ( 1 x x x B . A t ' 'aecni o s i o t A o Z : 1 - A 0 0 0 1 o 1 1 0 0 ) r 0 0 x x ) ' ' o Z r o t u u wt u n h gp a. ' 't ' ' 6 H 7 H ( 1 0 0 0 B t 0 1 1 1 B o ( 1 x x x B . A t ' 'aea ocni o s a o z:1-A 01 01 o 11 00) r 01 xx) '' o Z r l otuu s n wto t a . o ee,h r iag pb t enu p r s a dl ecs l tr T cn et ew e u p r n i u g p H w vrtee s a ew e p ec e n o r e e es o o vr b t en p e a d h a w a t . l ecs,i te a e f i5 o r ef h vl o b -. w a l p u t C d n mb r 0 ( 0 )t 3 D ( F ) a d1 7 ( F )aesei cnrlh rc r w i aen npi a l o e u es D 0 H o 1 1 H , n 2 D 7 H r p c l o t caat s h h r o -r tb a o e, c n e (o -i l a l, s a u tdb l . n o tee h rc r w r ue i teer d y frrnmi i cnrl n nd p yb )a tb l e e w Ma y fh s caat s ee sd n h al as o t s s o o t sa e a o e y a sn o (g SX EX a dpi e cnrle . om-ed, h haen w o sl eT erma i men gu cd s o a e . T ,T ) n r tr o t (g F r Fe )w i r o bo t.h e in ., n o ., c e n g a i flo e td y n
www3.ntu.edu.sg/home/ehchua/programming/java/DataRepresentation.html 16/25
4/7/12
ae r: 0 Hfr a (\ '. 9 o Tb ' t ) 0 Hfr i -edo n wi ( , \ ' a d0 Hfr ar g -eun(R ' ', h hae sda line delimiter A o L eFe r e le L ' n ) n D o C ra eR tr C , r )w i r ue s n n F i c ( aline separator, a k end-of-line)o tx f s T eei u fr n tl n s n adfri d l trU i sue fr et i . h r s not ae o t d r o le emi : n e s l e u y a n i e x 0 H ( n)Wi o sue0 0 H ( r n)Mas s 0 H ( r)Po rmmi l g a e sc a CC + Jv A " " n w s D A " \" \ , d \ , c ue D " " rga n a u g s uh s /+ / a \ . g n a (h hw s rae o U i ue A ( n) w i a c td n n ) s 0 H " " c e x \ . I po rmmi l g a e sc a CC + Jv,n - e (A )sd n tda ' n , ar g - tr (D ) s n rga n a u g s uh s /+ / a lef d 0 H i e oe s \ ' cra er un 0 H a g n a i e i e ' r ,a (9 ) s \ ' \ ' tb 0 H a ' t .
DC E
0 1 2
HX E
0 0 0 1 0 2
Maig enn
NL Nl U ul SH Sato O tr f Haig edn SX Sato Tx T tr f et
DC E
1 7 1 8 1 9
HX E
1 1 1 2 1 3
Maig enn
D1 Dvc C eie Cnrl1 oto D2 Dvc C eie Cnrl2 oto D3 Dvc C eie Cnrl3 oto
3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6
0 3 0 4 0 5 0 6 0 7 0 8 0 9 0 A 0 B 0 C 0 D 0 E 0 F 1 0
2 0 2 1 2 2
1 4 1 5 1 6 1 7 1 8 1 9 1 A 1 B 1 C 1 D 1 E 1 F
D4 Dvc C eie Cnrl4 oto NK Ngtv A eaie Ak c. SN Sn.Il Y yc de EB Edo T n f Tasiso rnmsin CN Cne A acl E M Edo n f Mdu eim
AK Akoldeet 2 C cnwegmn 3 BL Bl E el B S H T L F V T F F C R S O S I 2 4
Bc Sae'b 2 ak pc \' 5 Hrzna Tb oiotl a 't \' Ln Fe 'n ie ed \' Vria Fe etcl ed Fr Fe '' om ed f 2 7 2 8 2 9 2 6
SB Sbttt U usiue EC Ecp S sae I4 Fl S ie Sprtr eaao I3 Gop S ru Sprtr eaao I2 Rcr S eod Sprtr eaao I1 Ui S nt Sprtr eaao
7 F
DL Dlt E eee
4/7/12
I ln P r g eea d S a i . ai 1 i b cw r cmp t l wt te7b U - S Icd . h ti tefs 1 8 t i , ot u s n p n h Lt - s ak ad o aie i h -i SA CI o e T a s h it 2 aa u s n b h t , r caatr i Lt - ( d n mb r 0t 1 7(F ) itesme s SA CI o en mb r 1 8(0 )o1 9(F ) r h rc sn ai 1 c e u es o 2 7 H)s h a a U - S I C d u es 2 8 H t 5 9 H ae e n o , . n t si e . o e u es 6 (0 )o2 5( H ae i na flw : o as n d C d n mb r 1 0 A H t 5 F ) r g e soo s g F v l
Hx e A B C D E F
0
NS BP
D
SY H
I / C 8 5 h s 6p r . ei s h mot o S I -8 9 a 1 at B s e te s cmmo l ue P r1 P r2imen fr e t luo en(os, zc, O E s d n -sd at , at s a to C nr E rp a P lh C eh y a i H n ai , t , at fr o t E rp a ( ri , t , at fr ot E rp a ( tn n Lti , t , at fr u g r n ec P r 3 o S uh uo en T k h ec P r 4 o N r uo en E o i , av n ec P r 5 o a ) u s ) h s a a ) C ri P r6fr rb , at fr re, at fr e rw P r9fr uk h P r1 fr od , at 1fr h i at yic at o Aa i P r7 o G ek P r8 o H be , at o T ri , at 0 o N ri P r1 o T a P r l, l c s c , 1 w sa a d n P r 1 fr a i R P r 1 fr e i P r 1 fr rnh F n h ec P r 1 fr o t-atr 2 a b n o , at 3 o B l i at 4 o C l , at 5 o Fe c, i i , t at 6 o S uhEs n t m, c t c ns . e E rp a . uo en
Hx e 8 9
4/7/12
U i d oin l ue 1 b s( ldU S2 o U i d C aatrSt 2 b t)w i cnrpee t p t 6 , 6 n o e r i l ss 6 i c l C - r n o e h rc c g ay t ae c e eye h h a e rsn u o 5 3 , c 5 caatr Ih s i eb e ep n e t moeta 1 b scr nl s n s t 1b sT ern eo tel a cd sn h rc s t a s c en xa d d o r h n 6 i,ur t t d a 2 i. h a g fh e lo e i e. n t e y a t g I / C 1 6 6in w f m U 0 0 H t U 1 FFH (1b so a o t mio caatr , o ei a cr n a d S I 04 s o r O E o + 0 0 o + 0 FF 2 i r b u 2 l n h rc s cvr g l ur t n t l i e) n l e a c n h tra sr t T e oin l 6b rn eo U 0 0 H t U FFH (5 3 caatr i k o n a Basic ni t ioi l cps h r i 1 -i a g f + 0 0 o + FF 6 5 6 h rc s s n w s e s c i . ga t e) Multilingual Plane (MP, o ei a tema rl g a e i uecr nl T ecaatr o td B B )cvr g l h n l j a u g s n s ur t . h h rc s us e MP aecld o n e y e i r ae l Supplementary Characters, h hae o f q e t -sd w i r n tr u nl ue . c e y U i d h s w e cd gsh me: n o e a t o no i ce s c n UCS-2 (n esl h rc r e -2B t)U e 2b ts(6b s cvr g6 , 6caatr i teB . MPi U i r C aat St v a e ye ss ye 1 i) o ei 5 3 h rc s n h MP B : t, n 5 e s sf i to mot fh a pct n. C - in wo sl e uf e fr s o te p lai sU S2 s o bo t. in c i o e UCS-4 (n esl h rc r e - B t) ss b ts3 b s cvr gB a dte u p me tr caatr U i r C aat St 4 ye U e 4 ye (2 i) o ei MP n h sp l nay h rc s v a e : t, n e e.
Bt is
7 1 1 1 6 2 1
Uioe ncd
0000 0000 0xxx xxxx 000y 00yy yxxx yxxx zzyy zzyy yxxx yxxx 00uu 0uuu zzyy zzyy yxxx yxxx
UF8Cd T- oe
Bts ye
(SI) ACI
0xxx 1 xxxx 10yy 1xxx 2 1yyy 0xxx 11zz 1yyy 3 10zz 0yyy 1xxx 0xxx 110u 1uzz 4 11uu 0uzz 1yyy 1xxx 0yyy 0xxx
I U F8 U i d n mb r cr so d gt te7b A CI h rc r aep d e wt al d gzr;h s a te n T-, n o e u es or p n i o h -i S Icaat s r a d d i c e n t e h e i eo tu h s h an sme a ea A CI e c, T- cnb ue wt a sf ae s gA CI n o en mb r o 1 8a da o ew i a vl s S I H ne U F8 a e sd i l ot r ui S I U i d u es f 2 n b v, h h u . h l w n . c c ae l sf q e t ue , r e cd d ui moe b ts(- b ts U F8 g n rl rq i sl ss rg a d i r e r u nl sd ae no e s g s e y n r ye 24 ye) T- e eay e u e e t a e n s . l r s o cmp t l wt A CIT eda b c o U F8imoepoes gp w r ed dt u p c tecd d et i vr b o aie i S I h rw ak f T- s r rcsi o e n e e o n ak h o e u o t ai l b h . n s ae l gh U F8ite s p p l fr to U i d . e t. T- s h mot o u roma fr n o e n a c N ts oe: U F8ue 13b tso tecaatr i B (6b )a d4b ts o sp l nay h rc r o td B (1 T- ss - ye frh h rc sn MP 1 -i, n e t ye fr u p me tr caat s us e MP 2 e e i b) i. t T e 2 A CIh rc r (aiLt l tr d i, n p ntai s n) s o e ye Mot uo ena dMi l h 1 8 S Icaat s b s ai e es it a d u c t n i sue n b t. s E rp a n e c n t , gs u o g de d Es caatr uea2b t sq e c, h hi l e etn e Lt l tr (i t e marn aue gaea d at h rc s s e -ye e u ne w i n u s x d d ai e es wt i , c , ct, rv n c cd e n t h l d o oh r ce t , re, r n n H be , rb , n oh r C i s,a a eea dK ra (J) s treb t te acns G ek Ame i , e rw Aa i a d tes h ee Jp n s n oen CK ue he-ye ) a c . n sq e cs e u ne. Alh b tsecp te1 8A CI h rc r h v al d g' 'b . oh r od,h A CI ye, i aed g l e ye,xe th 2 S Icaat s ae e i 1 i I te w rste S Ib tswt l i t e, an tn h an ' 'b ,a b i ni da dd cd desy 0 i cn ed ti n eo e ai. t e f e l Example: (ncd:6AH57H Uioe 08 9D)
Uioe(C-)i 6AH=01 00 1 110B ncd US2 s 08 10 00 0 000 UF8i 1101 1001 1110B=E 8 AH T- s 1010 0000 0000 6 2 8
www3.ntu.edu.sg/home/ehchua/programming/java/DataRepresentation.html 19/25
4/7/12
Uioe(C-)i 57H=00 10 0 110B ncd US2 s 9D 11 01 1 111 UF8i 1100 1100 1110B=E A BH T- s 1011 0011 0111 5 5 D
Uioe ncd
xxxx xxxx xxxx xxxx 00uu zzyy 0uuu zzyy yxxx yxxx (uu) uuu0
UF1 Cd T-6 oe
ecdn noig
Bts ye
Sm a US2-n 2 ae s Co 101w wzzy 4 110w wzzy 101y yxxx 111y yxxx (ww=uuu-1 ww uu )
Tk n t ta fr h 6 5 6caatr i B ,h U F1 itesmea U S2( b ts H w vr4b ts r ue ae oe h to te 5 3 h rc sn MP te T-6 s h a e s C - 2 ye) o ee, ye ae sd . frh sp l nay h rc r o td te MP o te u p me tr caat s us e h B . e e i F r MPcaatr U F1 itesmea U S2 F r u p me tr caatr ec caatr e u e ap i1 -i oB h rc s T-6 s h a e, s C -. o sp l nay h rc s ah h rc rq i s a 6b e e, e r r t vl stefs f m te i -urg ts a g , u 8 0 \ D F ) h scn f m teo -urg ts a g (u C 0 a e,h itr h h hsr ae rn e( D 0 - u B F, e eo d r u r o g o \ t o h l sr ae rn e \ D 0 w o \DF) u F F.
4/7/12
s-ae line delimiter (r ocld l o end-of-line o E L T on npi a lcnrlh rc r aen o e : A (n -edo L) r O ) w o -r tb o t caat s r i l d 0 H L eFe r F . n e o e vv i a d0 H(ar g -euno C ) n D C ra eR tr r R. i Wi o s O ue O 0 H(R L,\ \ "a E L n w / S ss D A C + F"r n) s O . d D U i s s 0 H( ,\ "o l n e ue A L "n) n . x F y Ma ue 0 H(R "r) n . c ss D C ,\ "o l y
End-of-File (EOF) : O O] [ D T
Sadr tnad
Smlfe ipiid G21 B32 UC2 SUF8 TTaiinl BG rdtoa I5 US2 CUF8 T-
Caatr hrces
Cds oe
BC DB AD 03 58 81 4C C0 E98 EB9 52C 800 A4 BD 9D F3 58 8E 4C A7 E98 EAA 52C 8B7
4/7/12
4/7/12
Sse.u.rnf"0X" b.e() / Pithxcd ytmotpit(%2 , bgt); / rn e oe } Sse.u.rnl(; ytmotpitn) b.eid) brwn(; } } } US2 04 06 02 6A 57 02 [6btfxdlnt] C-: 08 09 0C 08 9D 01 1-i ie-egh H i , ! U-SI:4 6 2 3 3 2 [-i fxdlnt] SACI 8 9 C F F 1 8bt ie-egh H i , ? ? ! IO85-:4 6 2 3 3 2 [-i fxdlnt] S-891 8 9 C F F 1 8bt ie-egh H i , ? ? ! UF8 4 6 2 E 8 A E A B 2 [- btsvral-egh T-: 8 9 C 6 2 8 5 5 D 1 14 ye aibelnt] H i , ! UF1:F F 0 4 0 6 0 2 6 A 5 7 0 2 [- btsvral-egh T-6 E F 0 8 0 9 0 C 0 8 9 D 0 1 24 ye aibelnt] BM H O i , ! [yeOdrMr idctsBgEda] Bt-re-ak niae i-nin UF1B:0 4 0 6 0 2 6 A 5 7 0 2 [- btsvral-egh T-6E 0 8 0 9 0 C 0 8 9 D 0 1 24 ye aibelnt] H i , ! UF1L:4 0 6 0 2 0 A 6 7 5 2 0 [- btsvral-egh T-6E 8 0 9 0 C 0 8 0 D 9 1 0 24 ye aibelnt] H i , ! GK 4 6 2 C F B C 2 [- btsvral-egh B: 8 9 C 4 A A 3 1 12 ye aibelnt] H i , ! Bg:4 6 2 B 7 A 6 2 [- btsvral-egh i5 8 9 C 1 A 6 E 1 12 ye aibelnt] H i , !
4/7/12
Tx a :h rw r wto t xi t np r d T v wteH x a e y un e t "p n te i b co s gte i et d S ae ae i u ep ai ei .o i h e vl , o ed o o e " h f y h oi h f P h r o o e u l e n l e fr t fb ay ( ) oma o "i r"? . n ? Ut E i S ae aen tre3 -a tao l lad :h rw r, o f , 0d y r l n . r t e i y Lt k o i o h v ab t r h i , h hif tol nh es t ue cntg l b t enH x n n r l i , e me n w f u ae et co e w i s a t a c, ay o s,a o g ew e e a d oma v w y e c c s u e e f e. r ,. e . . T e oo i Jv po rm cnb ue t d p y e cd fraa r t e ( tg rcaatr n f ai -o t h flwn aa rga a e sd o i l h x o e o Jv Pi i si e e,h rc a d l t gp i ) l g sa mi v n e o n n:
1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0 pbi casPiteCd { ulc ls rnHxoe pbi sai vi mi(tig]ag){ ulc ttc od anSrn[ rs iti=135 n 24; Sse.u.rnl(Dcmli "+i; ytmotpitn"eia s ) / 135 / 24 Sse.u.rnl(Hxi "+ItgrtHxtigi) ytmotpitn"e s nee.oeSrn(); / 33 / 09 Sse.u.rnl(Bnr i "+ItgrtBnrSrn();/ 1000110 ytmotpitn"iay s nee.oiaytigi) / 1000101 Sse.u.rnl(Otli "+ItgrtOtltigi) ytmotpitn"ca s nee.ocaSrn(); / 301 / 07 Sse.u.rnf"e i %\" i; ytmotpit(Hx s xn, ) / 33 / 09 Sse.u.rnf"ca i %\" i; / 301 ytmotpit(Otl s on, ) / 07 ca c='' hr a; Sse.u.rnl(Caatri "+c; ytmotpitn"hrce s ) / a / Sse.u.rnf"hrce i %\" c; ytmotpit(Caatr s cn, ) / a / Sse.u.rnf"e i %\" (hr)) ytmotpit(Hx s xn, sotc; / 6 / 1 Sse.u.rnf"eia i %\" (hr)) / 9 ytmotpit(Dcml s dn, sotc; / 7 fotf=35; la .f Sse.u.rnl(Dcmli "+f; ytmotpitn"eia s ) / 35 / . Sse.u.rnl(la.oeSrn();/ 01c1(rcin1c Epnn=) ytmotpitnFottHxtigf) / x.p Fato=., xoet1 f=-.5; 07f Sse.u.rnl(Dcmli "+f; ytmotpitn"eia s ) / -.5 / 07 Sse.u.rnl(la.oeSrn();/ -x.p1(=18 E-) ytmotpitnFottHxtigf) / 018- F-., =1 dul d=1.2 obe 12; Sse.u.rnl(Dcmli "+d; ytmotpitn"eia s ) / 1.2 / 12 Sse.u.rnl(obetHxtigd) / 016037ad13(=.7ad037 E3 ytmotpitnDul.oeSrn(); / x.7ad037p F16037ad1 =) } }
I Els, o cnv wteh x o efr n cpe y u a i h e cd o integer pi t eJv vr b snd b gmo e s oo sI d b gp r et e i e r i aa ai l i e u mi v ae d a flw : e u es cv, l n p i "ai l p n l Sl t h " n " i etd ta g ) Jv Jv Pe rne. Pi t eDsl O t n V r b " a e e c te me u ( vr ae e n e r n l aa i e aa rf e cs. e . r i i a pi s mi v py o C ek Dsl h xd c la e (yesotca, tl g" h c " i a ea ei vl sb t,h r h ri , n ) py ma u , n o .
4/7/12
I 8b Lt -,h caatr y o ' 'irpee tda 0 1 0 0 B(r 1 ) n -i ai 1 te h rc smb l 1 s e rsne s 0 1 0 1 o 3 H. t n e I 1 -iU S2 te h rc r y o ' 'irpee tda 0 0 0 0 0 1 0 0 B n 6b C -,h caat smb l 1 s e rsne s 0 0 0 0 0 1 0 1 . t e I U F8 te h rc r y o ' 'irpee tda 0 1 0 0 B n T-,h caat smb l 1 s e rsne s 0 1 0 1 . e Iy u"d " 1 -is n di e e 1a dLt - caatr 1 o a tn " " y ucu g t srre f o a d a 6b i e n g r n ai 1 h rc ' ' r s i 1 , o o l e a upi . tg t n e rg d s
Gv te vl si h y r rpee t g i h i a e, te ae e rsni : e r u f n 1 a 6b u s n di e e; . 1 -i ni e n g r t g t 2 a 6b s n di e e; . 1 -i i e n g r tg t 3 t o8b u s n di e es . w -i ni e n g r t g t ; 4 t o8b s n di e es . w -i i e n g r tg t ; 5 a 6b U i d caatr . 1 -i n o e h rc s t c e; 6 t o8b I -8 91caatr . w -i S 8 5 - h rc s t O e. A s() 2 3 8 0 () 2 - 2 2 ; ) , 2 1 8 4 ; ) , 2 - 2 , 2 () * ; ' () U , * ; A , * . n: 4 , 2 1 ; 4 , 3 7 6 ( 0 4 ; 2 , 2 ( 0 4 ; 1 8 4 ; ' ' ' ; N L ' ' P D ' ' 1 2 3 4 5 6
Feedback, comments, corrections, and errata can be sent to Chua Hock-Chuan (ehchua@ntu.edu.sg) | HOME
www3.ntu.edu.sg/home/ehchua/programming/java/DataRepresentation.html
25/25