Académique Documents
Professionnel Documents
Culture Documents
NumberingSystemsTutorial
NumberSystems
DecimalSystem
Mostpeopletodayusedecimalrepresentationtocount.Inthedecimalsystemthereare10
digits:
0,1,2,3,4,5,6,7,8,9
Thesedigitscanrepresentanyvalue,forexample:
754.
Thevalueisformedbythesumofeachdigit,multipliedbythebase(inthiscaseitis10
becausethereare10digitsindecimalsystem)inpowerofdigitposition(countingfromzero):
Positionofeachdigitisveryimportant!forexampleifyouplace"7"totheend:
547
itwillbeanothervalue:
Importantnote:anynumberinpowerofzerois1,evenzeroinpowerofzerois1:
BinarySystem
Computersarenotassmartashumansare(ornotyet),it'seasytomakeanelectronicmachine
withtwostates:onandoff,or1and0.
Computersusebinarysystem,binarysystemuses2digits:
http://www.electronics.dit.ie/staff/tscarff/number_systems/number_systems.html
1/5
7/7/2015
NumberingSystemsTutorial
0,1
Andthusthebaseis2.
EachdigitinabinarynumberiscalledaBIT,4bitsformaNIBBLE,8bitsformaBYTE,two
bytesformaWORD,twowordsformaDOUBLEWORD(rarelyused):
Thereisaconventiontoadd"b"intheendofabinarynumber,thiswaywecandeterminethat
101bisabinarynumberwithdecimalvalueof5.
Thebinarynumber10100101bequalstodecimalvalueof165:
HexadecimalSystem
HexadecimalSystemuses16digits:
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F
Andthusthebaseis16.
Hexadecimalnumbersarecompactandeasytoread.
Itisveryeasytoconvertnumbersfrombinarysystemtohexadecimalsystemandviceversa,
everynibble(4bits)canbeconvertedtoahexadecimaldigitusingthistable:
2/5
7/7/2015
NumberingSystemsTutorial
0000
1
2
0001
0010
1
2
0011
0100
5
6
0101
0110
5
6
0111
8
9
1000
1001
8
9
10
1010
11
1011
12
13
1100
1101
C
D
14
1110
15
1111
Thereisaconventiontoadd"h"intheendofahexadecimalnumber,thiswaywecan
determinethat5Fhisahexadecimalnumberwithdecimalvalueof95.
Wealsoadd"0"(zero)inthebeginningofhexadecimalnumbersthatbeginwithaletter(A..F),
forexample0E120h.
Thehexadecimalnumber1234hisequaltodecimalvalueof4660:
ConvertingfromDecimalSystemtoAnyOther
Inordertoconvertfromdecimalsystem,toanyothersystem,itisrequiredtodividethedecimal
valuebythebaseofthedesiredsystem,eachtimeyoushouldremembertheresultandkeep
theremainder,thedivideprocesscontinuesuntiltheresultiszero.
Theremaindersarethenusedtorepresentavalueinthatsystem.
http://www.electronics.dit.ie/staff/tscarff/number_systems/number_systems.html
3/5
7/7/2015
NumberingSystemsTutorial
Let'sconvertthevalueof39(base10)toHexadecimalSystem(base16):
Asyouseewegotthishexadecimalnumber:27h.
Allremainderswerebelow10intheaboveexample,sowedonotuseanyletters.
Hereisanothermorecomplexexample:
let'sconvertdecimalnumber43868tohexadecimalform:
Theresultis0AB5Ch,weareusingtheabovetabletoconvertremaindersover9to
correspondingletters.
Usingthesameprinciplewecanconverttobinaryform(using2asthedivider),orconvertto
hexadecimalnumber,andthenconvertittobinarynumberusingtheabovetable:
Asyouseewegotthisbinarynumber:1010101101011100b
http://www.electronics.dit.ie/staff/tscarff/number_systems/number_systems.html
4/5
7/7/2015
NumberingSystemsTutorial
SignedNumbers
Thereisnowaytosayforsurewhetherthehexadecimalbyte0FFhispositiveornegative,it
canrepresentbothdecimalvalue"255"and"1".
8bitscanbeusedtocreate256combinations(includingzero),sowesimplypresumethatfirst
128combinations(0..127)willrepresentpositivenumbersandnext128combinations
(128..256)willrepresentnegativenumbers.
Inordertoget"5",weshouldsubtract5fromthenumberofcombinations(256),soitwe'llget:
2565=251.
Usingthiscomplexwaytorepresentnegativenumbershassomemeaning,inmathwhenyou
add"5"to"5"youshouldgetzero.
Thisiswhathappenswhenprocessoraddstwobytes5and251,theresultgetsover255,
becauseoftheoverflowprocessorgetszero!
Whencombinations128..256areusedthehighbitisalways1,sothismaybeusedtodetermine
thesignofanumber.
Thesameprincipleisusedforwords(16bitvalues),16bitscreate65536combinations,first
32768combinations(0..32767)areusedtorepresentpositivenumbers,andnext32768
combinations(32767..65535)representnegativenumbers.
Copyright20032005Emu8086,Inc.
Allrightsreserved.
http://www.emu8086.com
http://www.electronics.dit.ie/staff/tscarff/number_systems/number_systems.html
5/5