WHH eries r QHHH gomputer ystems
hee i gyxisyx
rogrmmer9s quide
efghi
r rt xoF QPTSHEWHHIS
rinted in FFeF IWVW
eond idition
iIHVW he informtion ontined in this do ument is su jet to hnge
without notieF
riviEegueh weui xy eex yp ex
usxh sr iqeh y rs weisevD sxgv hsxqD
f xy vswsih yD ri swvsih eexsi yp
wigrexefsvs exh psxi py e esg ve
yiF rewlettEkrd shll not e lile for errors
ontined herein or use of this mterilF
rewlettEkrd ssumes no resp onsiilit y for the use or
reliilit y of its softwre on equipment tht is not furnished y
rewlettEkrdF
his do ument ontins proprietry informtion whihis
proteted y opyrightF ell rights re reservedF xo prt of
this do umentmy e photo opiedD repro duedD or trnslted
to nother lnguge without the prior written onsentof
rewlettEkrd gompnyF
gopyright IWVW y rewlettEkrd gompny he following tle lists the printings of this do umentD together
rint ristory
with the resp etive relese dtes for eh editionF he softwre
version indites the version of the softwre pro dut t the time
this do umentws issuedF wny pro dut releses do not require
hnges to the do umentF hereforeD do not exp et oneEtoEone
orresp ondene etween pro dut releses nd do ument editionsF
idition hte oftwre
ersion
pirst idition xovem er IWVU eFHIFHH
p dte I tuly IWVV eFIHFHH
eond idition yto er IWVW eFQHFHH
iii iv he ht yp es gonversion rogrmmer9s wnul is intended for
refe
wi v progrmmers who re exp eriened in one or more highElevel
progrmming lngugesF he purp ose of the mnul is to help the
progrmmer who needs to reeive nd pss dt ross lnguges or
progrmming environmentsF
his guide is prt of the rogrmmer eriesF yther mnuls in the
series re depited in the do umenttion mp t the front of the
mnulF he mnuls for sp ei progrmming lnguges mye
useful s wellY the most ommon re listed elowX
r fusiness fesgGv eferene wnul @QPUISEWHHHIAF
r g rogrmmer9s quide @WPRQREWHHHPAD r g eferene
wnul @WPRQREWHHHIAD r gGv eferene wnul upplement
@QISHTEWHHHIAD nd r gGv virry eferene wnul
upplement @QHHPTEWHHHIAF
r gyfyv ssGv rogrmmer9s quide @QISHHEWHHHPA nd
gyfyv ss eferene wnul @QISHHEWHHHIA nd gyfyv ssGv
eferene wnul upplement @QISHHEWHHHSAF
r pyex UUGv eferene wnul @QISHIEWHHIHA nd r
pyex UUGv rogrmmer9s quide @QISHIEWHHIIAF
r sl eferene wnul @QISHPEWHHHIA nd r sl
rogrmmer9s quide @QISHPEWHHHPAF
r qGv rogrmmer9s quide @QHQIVEWHHHIA nd r q
eferene wnul @QHQIVEWHHHQAF
gompiler virryGv eferene wnul @QPTSHEWHHPWA my lso e
usefulF
ghpter ID sntro dutionD gives n overview of the mnul nd of
the topi of dt typ esD their formtD storgeD nd onversionF st
explins wht primitive dt typ es re reognized y wi v nd
its susystemsD why dt onversion my e neessryD nd the
dierenes in dt representtion etween the xtive wo de nd
gomptilit y wo de progrmming environments in wi vF
ghpter PD pormtting ht yp esD presents the formts of the
vrious dt typ es supp orted on wi v nd its susystemsF
fit formts re pituredD eld oundries givenD nd formtting
onventions explinedF e tle ompres the orresp ondene of
primitiv e dt typ es ross system intrinsis nd progrmming
lngugesF
ghpter QD gonverting ht yp esD tkes eh of the primitive dt
typ esD one y oneD nd gives some suggestions for onverting to eh
of the other dt typ esF
epp endix eD egs s nd ifghsg go de luesD shows the hrter
o de vlues with their deimlD o tlD nd hexdeiml equivlentsF
v st would e most useful to skim the entire mnul oneD then lo ok up
sp ei topis s neededF he le of pigures lists the vrious it
formt mpsF vo ok t the le of gontentsD le of lesD nd
index for other sp ei topisF
vi gontents
IF sntro dution
row ho the rogrmmer nd the gomputer
gommunite htc F F F F F F F F F F F F F IEI
hening ht yp es F F F F F F F F F F F F F F IEP
rimitive ht yp es F F F F F F F F F F F F F IEP
sntrinsi ht yp es F F F F F F F F F F F F F IEP
vnguge ht yp es F F F F F F F F F F F F F IEQ
pormtting ht yp es F F F F F F F F F F F F F IEQ
rogrmming invironment F F F F F F F F F F IEQ
rogrmming vnguges F F F F F F F F F F F IER
gonverting ht yp es F F F F F F F F F F F F F IES
sing hierentyp es ogether F F F F F F F F IES
ssing fetween rogrmming invironments F F IES
ssing eross rogrmming vnguges F F F F F IES
PF pormtting ht yp es
eognizing rimitive ht yp es F F F F F F F F PEI
ghrter F F F F F F F F F F F F F F F F F F PEP
egs s F F F F F F F F F F F F F F F F F F PEP
ifghsg F F F F F F F F F F F F F F F F F PEQ
xumeri F F F F F F F F F F F F F F F F F F F PER
snteger F F F F F F F F F F F F F F F F F F PER
nsigned snteger F F F F F F F F F F F F F PER
igned snteger F F F F F F F F F F F F F F PES
el F F F F F F F F F F F F F F F F F F F PEU
siii or rQHHH pormt F F F F F F F F F PEV
ingle or houle reision F F F F F F F F F PEV
pields of el xumer F F F F F F F F F F PEV
siii el xumer pormt F F F F F F F F PEW
siii gonversion ixmple F F F F F F F F F PEIH
rQHHH el xumer pormt F F F F F F F PEIP
heimls F F F F F F F F F F F F F F F F F PEIR
ked heiml pormt F F F F F F F F F F PEIS
npked heiml pormt F F F F F F F F F PEIT
plotingEoint heiml pormt F F F F F F F PEIT
pormtting ht in rogrms F F F F F F F F F F PEIW
xw nd gw rogrmming invironments F F F F PEIW
rogrmming vnguges F F F F F F F F F F F PEPH
vnguge xotes F F F F F F F F F F F F F F PEPP
sntrinsis F F F F F F F F F F F F F F F F PEPP
r fusiness fesgGv F F F F F F F F F PEPP
r gGv F F F F F F F F F F F F F F F F PEPP
gontentsEI r gyfyv s sGv F F F F F F F F F F F F PEPQ
r pyex UUGv F F F F F F F F F F PEPR
r slGv F F F F F F F F F F F F F F PEPR
QF gonverting ht yp es
ssing ht F F F F F F F F F F F F F F F F F QEI
gonverting from ghrterX F F F F F F F F F F F QEP
o yther ghrter F F F F F F F F F F F F F F QEP
fetween egs s nd ifghsg F F F F F F F F QEP
fetween xtive vnguges F F F F F F F F F QEP
fetween xumeri pormts F F F F F F F F F F QEQ
osnteger F F F F F F F F F F F F F F F F F F QER
o el F F F F F F F F F F F F F F F F F F F QER
oked heiml F F F F F F F F F F F F F F QES
gonverting from snteger F F F F F F F F F F F F F QES
o ghrter F F F F F F F F F F F F F F F F QES
o yther snteger F F F F F F F F F F F F F F F QET
o el F F F F F F F F F F F F F F F F F F F QET
oked heiml F F F F F F F F F F F F F F QET
gonverting prom el F F F F F F F F F F F F F F QET
o ghrter F F F F F F F F F F F F F F F F QET
osnteger F F F F F F F F F F F F F F F F F F QET
o yther el F F F F F F F F F F F F F F F F QEU
yverow nd nderowF F F F F F F F F F F QEV
eury F F F F F F F F F F F F F F F F F QEV
runting F F F F F F F F F F F F F F F F QEV
oked heiml F F F F F F F F F F F F F F QEV
gonverting from ked heiml F F F F F F F F F QEW
o ghrter F F F F F F F F F F F F F F F F QEW
osnteger F F F F F F F F F F F F F F F F F F QEW
o el F F F F F F F F F F F F F F F F F F F QEW
o yther heimls F F F F F F F F F F F F F F QEIH
eF egs s nd ifghsg go de lues
sndex
gontentsEP pigures
PEIF fit pormtX egs s ghrter F F F F F F F F F PEQ
PEPF fit pormtX ifghsg ghrter F F F F F F F F PEQ
PEQF fit pormtX QPEfit snteger F F F F F F F F F F PEU
PERF fit pormtX ingleEreision el in siii
plotingEoint xottion F F F F F F F F F F PEII
PESF fit pormtX houleEreision el in siii
plotingEoint xottion F F F F F F F F F F PEIP
PETF fit pormtX ingleEreision el in rQHHH
plotingEp oint xottion F F F F F F F F F F PEIQ
PEUF fit pormtX houleEreision el in rQHHH
plotingEp oint xottion F F F F F F F F F F PEIR
PEVF fit pormtX fgh xile F F F F F F F F F F F PEIS
PEWF fit pormtX ked heiml F F F F F F F F F F PEIT
PEIHF fit pormtX plotingEoint heiml F F F F F F PEIV
PEIIF fit pormtX hort plotingEoint heiml F F F F PEIV
les
IEIF vnguges upp orted on wi v F F F F F F F IER
PEIF wi v snteger yp es F F F F F F F F F F F F PER
PEPF nges nd euries for plotingEoint el
xum ers F F F F F F F F F F F F F F F F F PEV
PEQF hetermining the fseEen iquivlent of n siii
el xumer F F F F F F F F F F F F F F F PEII
PERF nge nd reision for plotingEoint heimls F PEIU
PESF gorresp ondene of ht yp es eross vngugesX
sntrinsisD fesgD nd g F F F F F F F F F F PEPH
PETF gorresp ondene of ht yp es eross vngugesX
gyfyvD pyexD nd sl F F F F F F PEPI
eEIF egs sGifghsg ghrter ets F F F F F F F F eEP
gontentsEQ
I
sntrodution
his hpter gives you kground on reting nd reeiving dt in
forms tht your progrm nd the op erting system understndF st
presents dt typ es dened y the designers of WHH eries r QHHH
gomputer ystemsD nd the prop er formt for those typ esF
he omputer n reeive informtionD mnipulte itD nd store
row ho the
itF st n ess stored informtionD red itD nd send it outF ell
rogrmmer nd the
informtion is represented in the omputer y omintions of ones
gomputer
nd zerosD eh one lled inry itF
gommunite htc
ext hrters nd numeri vlues re pssed in nd out of the
omputer s sequene of its in xedEsized hunks lled wordsF
rewlettEkrd reision erhiteture @rEeA design is sed on
QPEit @REyteA wordF
egisters re designed to hold one QPEit word of dtF feuse
they re fst ut ostlyD registers typilly hold only the dt eing
urrently pro essed nd the most frequently used simple mhine
instrutionsF
he designers lso dene wht typ es of dt the system will
reognize nd how ehtyp e is to e formttedF his wyD the
system nd the progrmmer n ess nd pss dt in omplete
nd meningful lo ksF he progrmmer often uses highElevel
lnguge ompiler to trnslte etween the system nd userF
sntrodution IEI he designers of the omputer dene ertin primitive system dt
hefining ht ypes
typ es in order to reeive inputD store or mnipulte dtD nd return
informtion in preditle wyF
row pro ess will use dt input dep ends on the ontextF sf
pro ess requires ertin dt typ eD it will ttempt to interpret input
s tht typ eF por exmpleD if you pss QP inry its to n intrinsi
prmeter tht requires le ddressD it my ttempt to ess the
ell t tht lo tion in memoryFsfyou pss the sme QP its to
prmeter tht requires hrter rryDitmy print fourEletter
wordF sf you pss the sme QP its to prmeter tht requires
TREit otingEp oint rel vlueD you my use n error or progrm
ortF
he rEe instrution set is designed to op erte on ertin
rimitive ht ypes
fundmentl dt typ esF he follo wing dt typ es re reognized y
wi v nd its susystemsX
ghrtersF
he follo wing numeri typ esX
sntegersF
el num ers @in otingEp oint nottionAF
heimlF
elthough deiml is not relly system primitivetyp eD it is
xote
inluded in this mnul euse it is so widely used on wi vF
plotingEp oint deimls re used y fesgY pked nd unpked
deimls re used y gyfyv nd qF
he ompilers of highElevel lnguges running on wi v hve
sntrinsi ht ypes
mehnisms to ess the systemEdened pro edures lled intrinsisF
wi v intrinsi prmeters reognize the follo wing dt typ esX
eddress @ dAF
erry@e AF
fo olen @ f AF
ghrter @ g AF
sntegersX igned @ s A nd nsigned @ AF
el @ AF
eord @ e AF
ghrterD integerD nd rel num ers re system primitiv e typ esF
eddress nd fo olen typ es re num ers with sp eil usesF erry nd
reord re strutures tht group dtF
IEP sntrodution ome highElevel progrmming lnguges running on wi v dene
vnguge ht ypes
their own dt typ es sed on the primitivetyp esF he lnguge
ompiler mkes ny neessry onversions etween the primitive dt
typ es nd the lngugeEdep endent dt typ esF his onversion is
trnsprent to the progrmmerF hese typ es re desri ed in the
pproprite lnguge mnuls in the vnguge wnul eriesF
vnguges my simply renme the primitivetyp eD like the integerD
system typ e ommon to ll lngugesF vnguges my use the
system typ es s uilding lo ks to rete more omplex dt
strutureF por exmpleD the rry is not primitiv e typ eD ut is
dened y progrmming lnguges s onneted group of dtD ll
of the sme typ eF
he designers of the omputer sp eify sp ei formts for eh dt
pormtting ht
typ e so the omputer n ess or output sequene of its in
ypes
preditle wyF
he formt sp eies lignment nd sizeF he lignment predits the
@strtingA oundryY it tells where meningful unit of informtion
eginsF he size tells the length of the unit of informtionY it predits
the endF
he prop er formt for dt typ e dep ends on two ftorsX
rogrmming environmentF
rogrmming lngugeF
wi v supp orts two progrmming environmentsX xtive wo de
rogrmming
@xwA nd gomptiilty wo de @gwAF e progrm n e designed
invironment
to run in xw or in gwD or to swith k nd forth etween
suroutines in eh of themF
xw tkes full dvntge of rewlettEkrd reision erhiteture
@rEeAD whih is sed on QPEit wordF gw emultes the wi
Gi op erting systemD whih is sed on ITEit wordF
sn this mnulD ssume tht dt typ es re wi v xw dt typ esD
xote
unless gw is sp eilly mentionedF
sntrodution IEQ ihenvironment supp orts its own highElevel lnguges nd
rogrmming
ompilersF wost re shown in le IEIF
vnguges
le IEIF vnguges upported on wi v
xtivewode gomptiility wo de
r fusiness fesgGv r fusiness fesgG
r gGv
r gyfyv s sGv gyfyv s sG
r pyex TTG
r pyex UUGv r pyex UUG
r slGv r slG
r qGv qG
vG
por lngugeEsp ei dt typ es nd formtting onventionsD onsult
the pproprite lnguge mnulF
r fusiness fesgGv eferene wnul @QPUISEWHHHIA
r g eferene wnul @WPRQREWHHHIA nd r gGv eferene
wnul upplement @QISHTEWHHHIA
r gyfyv ssGv rogrmmer9s quide @QISHHEWHHHPA
gyfyv ss eferene wnul @QISHHEWHHHIA nd gyfyv ssGv
eferene wnul upplement @QISHHEWHHHSA
r pyex UUGv eferene wnul @QISHIEWHHIHA
r pyex UUGv rogrmmer9s quide @QISHIEWHHHPA
r sl eferene wnul @QISHPEWHHHIA
r sl rogrmmer9s quide @QISHPEWHHHPA
IER sntrodution ou mywnttohnge the form of informtionF ht output n
gonverting ht
e reted y one wi pro ess tht nnot e used in nother
ypes
without trnsltion or onversionF ln for onversion if you pss
dt to e used in the following situtionsX
with dt of nother typ e
etween progrmming environments
ross progrmming lnguges
vnguge ommndsD system intrinsisD nd ompiler lirry routines
help you onvert etween typ es nd formtsF
ou my need to mke dierenttyp es of dt together omptile to
sing hifferent ypes
use them in progrmF por exmpleD to lulte the totl ost of
ogether
pro dutD you my need to multiply prie y the num er soldF sf the
prie is stored s egs s dt typ e nd the num er sold is stored s
integerD one of them will hve to e onverted to the sme dt typ e
s the otherF
uroutines re lredy ville for mny ommon onversionsF
here re lso intrinsis t the system levelD nd ommnds within
progrmming lnguges to onvertF
ghpter P denes the xw primitivetyp es nd provides their it
mpsF ghpter Q gives some onversion metho dsF
wi Gi nd wi v in gomptiility wo de @wi v gwA
ssing fetween
re sed on ITEit wordY wi v in xtive wo de @wi v
rogrmming
xwA is sed on QPEit wordF ome dt typ es re represented
invironments
dierentlyFpor exmpleD rel num er in gwEompiled progrm
willD y defultD e in rQHHH formtF he sme rel vlue in n
xwEompiled progrm willD y defultD e in siii formtF
sf onversion is neessryD onsider reEompiling routinesD writing
suroutines to reformtD or using system intrinsisF
he highElevel lnguges do not ll reognize the sme primitive dt
ssing eross
typ esF gyfyv uses the deiml dt typ eD whih is not reognized
rogrmming
yslY howeverD the otingEp oint rel numer typ e is mutully
vnguges
understo o d ysl nd wi vD ut is not reognized y
gyfyvF
vnguges my dene their own omplex dt typ es tht nnot e
interpreted y other lngugesF sf you pss dt etween routines
tht do not use the sme typ es or formtsD you lose integrity nd
meningF he reeiving routine my not e le to red the dt t
llF st my divide the its it reds into the wrong size hunksF st my
interpret the rrngement of its y its own formtting onventionsF
he result ould e ompletely dierent informtion thn you
intendedF
sntrodution IES ou must pln for onversion if progrm uses suroutine written
in lnguge with inomptile typ esF ome lnguges hve
ommnds tht trnslte diretly s dt is red in nd written outF
ou my need to write routine to trnsform the dt indiretlyF
emem er tht ll the dt used in ny wi lnguge is primitive
dt typ e or is sed on primitivetyp eF ou ould write one
routine to trnslte dt from the rst lnguge typ es into primitive
system typ esD nd then nother routine to trnslte those system
typ es into form the seond lnguge n useF
IET sntrodution P
pormtting ht ypes
his hpter helps you understnd the dt typ es supp orted on
wi vF he rst prt of the hpter denes nd desri es the
primitiv e dt typ es reognized y wi v xtive wo de systems
nd susystemsD inluding it formts nd lignmentsF he seond
prt desri es some formtting onsidertions in wi v supp orted
progrmming lnguges nd environmentsF
ht is n strtion of informtionF ht must e strutured in
eognizing
form tht the omputer is designed to pro essY dt onversion is the
rimitive ht ypes
trnsltion of informtion to form eptle to the omputerF
he WHH eries r QHHH gomputer ystems instrution set is
designed to op erte on ertin fundmentl dt typ esF he follo wing
dt typ es re reognized y wi v nd its susystemsX
ghrtersF
he follo wing numeri typ esX
sntegersF
el num ers @in oting p oint nottionAF
heimlsX pkedD unpkedD nd otingEp ointF
elthough deiml is not relly system primitivetyp eD it is
xote
inluded in this mnul euse it is so widely used on wi vF
plotingEp oint deimls re used y fesgY pked nd unpked
deimls re used y gyfyv nd qF
ih dt typ e requires sp ei it formtF sn this mnulD it
elds re desri ed s @ it X length AD where it is the rst it in the
eld nd length is the num er of onseutive its in the eldF por
exmpleD its @IQXQA4 refers to its IQD IRD nd ISF fit H is the most
signint itF
pormtting ht ypes PEI ghrter o de formts re primitive dt typ esF ghrters re the
ghrter
lettersD num ersD nd sym ols on your key ordF he omputer
reltes eh lphnumeri hrter to n VEit @one yteA inry
num erD ording to orresp ondene o deF ome of the hrters
re esily displyleD like C D c D V D nd z Y some re notD like lnk
spe or the rrige returnF
wi supp orts the two ommon emerin inglish hrter o desX
egs s @emerin tndrd go de for snformtion snterhngeA nd
ifghsg @ixtended finry go ded heiml snterhnge go deAF
everl nturl lnguge typ es re lso supp ortedF ee epp endix e
for egs s nd ifghsg o des nd equivlentsF
ghrter dt typ es re useful for storing strings of sym ols like
nmesD ddressesD or identition num ersD nd for reding the
key ord or writing to the sreenF emem erD vriles sved s
dt typ e hrter re reognized y the omputer s sym olsD not
s numeri vluesF
egss
wi nd its susystems use egs s dt typ e to representhrter
dtF egs s is the formt dopted y exsD the emerin xtionl
tndrds snstituteF wost wi interfes use egs s to ept or
return hrter dtF
epp endix e shows the egs s nd ifghsg hrter o de vluesD
long with their deimlD o tlD nd hexdeiml equivlentsF
egs s is used in this guide s the nme of dt typ eF egs s dt
typ e orresp onds to the egs s hrter o de formtF he o des for
yte vlues in the rnge H to IPU onform to the egs s stndrd
formtF fyte vlues in the rnge IPV to PSS re interpreted using
rewlettEkrd9s extended ywexV hrter setF wi v nd
its susystems use vlues in this rnge to supp ort extended @VEitA
hrter setsF
PEP pormtting ht ypes pigure PEI shows the egs s dt typ e it formtF
pigure PEIF fit pormtX egss ghrter
ifghsg
ifghsg is nother o ding formt widely used in the omputer
industry for hrter dtF vike egs sD it is sed on the yteF
ifghsg is used in this guide s the nme of dt typ eF ifghsg
dt typ e orresp onds to ifghsg hrter o de formt for yte
vlues in the rnge H to PSSF
epp endix e shows the egs s nd ifghsg hrter o de vluesD
long with their deimlD o tlD nd hexdeiml equivlentsF
pigure PEP shows the it formt for ifghsg dt typ eF
pigure PEPF fit pormtX ifghsg ghrter
pormtting ht ypes PEQ wi v susystems supp ort three primitiv e dt typ es for num ersX
xumeri
sntegerF
elF
heimlF
snteger
en integer is ny p ositiv e or negtive whole num erD inluding zeroF
sntegers re useful for ounting nd for inrementing in lo opsF igned
integers re useful form for exhnging numeri dt etween
lngugesF
wi v integers n e VD ITD QPD or TR its longF hey n e
unsigned or signed @C or AF igned integers re represented in twos
omplement formF
le PEIF wi v snteger ypes
ize yp e nge tored etX
VEitX unsigned H to PSS yte ddresses
ITEitX signed QPDUTV to QPDUTU hlfEw ord ddresses
unsigned H to TSDSQS hlfEw ord ddresses
QPEitX signed PDIRUDRVQDTRV to PDIRUDRVQDTRU word ddresses
unsigned H to RDPWRDWTUDPWS word ddresses
he hrt elow shows the representtion of the whole numer
@seEtenA UQ s n unsigned integerD signed p ositiv e num erD nd
signed negtive num erF
nsigned igned
ositive xegtive
@UQA @CUQA @ UQA
HIHHIHHI HIHHIHHI IHIIHIII
nsigned sntegerF nsigned integers re stored in the omputer in
their seEtwo formF sf you re reding or writing unsigned integers
in lngugeD the ompiler onverts for youD ording to the
formtting onventions of the individul lngugeF
n
en unsigned n Eit num er n representnyvlue from H to P IF
PER pormtting ht ypes eding n nsigned sntegerX yne metho d of reding n unsigned
integer s seEten vlue is to onsider the its s olumns whose
vlues re p owers of twoF he rightmost @lest signintA it is the
H
units olumn nd hs weightofP D or IF qoing towrd the left @the
most signint itAD the olumns hve progressively greter weightX
H I P n EI
P DP DP D FFF P F he deimlEsed vlue of unsigned inry
num ers is omputed ymultiplying the vlue in eh olumn y the
weight of the olumnD nd then dding ll the resultsF en unsigned
H Q T
integer represented with ones in the P DP D nd P olumns nd zeros
in ll the other olumns would e omputed s followsX
H Q T
IB@P A C IB@ P A C IB@P A a UQF
riting n nsigned sntegerX yne metho d of mnully determining
the unsigned integer representtion of seEten vlue is to use
suessive sutrtionF por exmpleD the lrgest p ower of P tht
T
is less thn or equl to the vlue of deimlEse UQ is P D or TRF
utrting TR from UQ leves reminder of WF he lrgest p ower of
Q
P tht is less or equl thn W is P D or VF utrting V from W leves
reminder of IF he only p ower of P tht is less thn or equl to
H
IisP D or IF his leves reminder of HD so the omputtion is
H Q
nishedF husD UQ is represented in inry with I in the P D the P D
T
nd the P olumns nd zero in ll the othersF
igned sntegerF igned integers re stored in the omputer in twos
omplement formF sf you re reding or writing signed integers in
lngugeD the ompiler onverts for youD ording to the formtting
onventions of the individul lngugeF
e signed n Eit integer in twos omplement form n representny
n I n I
vlue from @P AtoCP IF
hen the n Eit p ositiv e integer i is dded to its n Eit integer
negtive @omplementAD i D nd oth re in twos omplement formD
the result is lwys n n Eit zeroF
eding igned sntegerX he omputer represents oth p ositiv e
nd negtive num ers in twos omplement form muh the sme
wy tht it would represent n unsigned integerX eginning t
the rightmost @lest signint itA nd going towrd the leftD the
H I P n I
olumns hve progressively greter weightX P DP DP DFFFP F he
only dierene is tht the most signint it of twos omplement
n I
numer is negtive F ht isD it hs weightof @P AF
o mnully onvert signed integer in twos omplement form to
seEten integerD you n use the olumn metho d explined in
nsigned sntegersD oveF roweverD you give the leftmost olumn of
n I
twos omplementnumer weightof @P AF
pormtting ht ypes PES sn the exmple elowD this metho d is used to interpret the signed
inry integers HIHIHIHI nd IHIHIHIHD written in twos omplement
formD s deimlEsed integersX
@HIHIHIHIA a the sum ofX @IHIHIHIHA a the sum ofX
se P se P
H H
@I x P A a I @H x P A a H
I I
@H x P A a H @I x P A a P
P P
@I x P A a R @H x P A a H
Q Q
@H x P A a H @I x P A a V
R R
@I x P A a IT @H x P A a H
S S
@H x P A a H @I x P A a QP
T T
@I x P A a TR @H x P A a H
U U
@H x @P AA a H @I x @P AA a IPV
@HIHIHIHIA a VS nd @IHIHIHIHA a VT
se P se IH se P se IH
riting igned sntegerX gonverting signed seEten numer to
twos omplement form is not diultF
ou n represent the p ositive signed integers just s explined in
nsigned sntegersD oveF
ou n represent negtive integer quikly nd esily using the
follo wing tehniqueD whih tkes dvntge of the prop erties of inry
num ersX pirstD ignoring the signD represent the vlue s n unsigned
inry integerF xextD reverse ll the Hs nd IsF pinllyD dd I to the
resultF husD the twos omplement of IHIHIHIH is @HIHIHIHI C IAD or
HIHIHIIHF
ou n hekyour onversion y dding the p ositiv e nd negtive
num ers @in twos omplement formA to see if they totl zeroF prom
the exmple oveD notie tht dding the VEit integer IHIHIHIH
to its twos omplementD HIHIHIIHD yields WEit resultD IHHHHHHHHF
roweverD the system denes the result typ e to e VEit integer nd
reognizes only the V zerosD so the result is zeroF
PET pormtting ht ypes pigure PEQ shows it formts for the QPEit integer typ eF
pigure PEQF fit pormtX QPEfit snteger
el
e rel numer is vlue in the set of zero nd the p ositiveor
negtive rtionl num ersF igned integers nd frtions re
inludedD lthough frtions my e pproximtedF smginry
nd omplex num ers re not inluded in the set of rel num ersD
lthough highElevel lnguges myhve onstruts for storing nd
working with themF
he rel dt typ e is useful form for representing very lrge or
smll vluesF p eil formts re reserved to represent zeroD innityD
nd xx @not num erAF
el dt typ e represents rel num ers y using typ e of
otingEp ointD or sientiD nottionF sn this nottionD you generlly
express very lrge or very smll num er s frtion multiplied
ypower of the num er seF por exmpleD the seEten