Professional Documents
Culture Documents
Number System
NumberSystem
Dr.A.Sahu
Dept of Comp. Sc. & Engg.
DeptofComp.Sc.&Engg.
IndianInstituteofTechnologyGuwahati
1
Outline
NumberSystem
Decimal,Binary,Octal,Hex
D i l Bi
O t l H
Conversion(onetoanother)
DecimaltoBinary,Octal,Hex&ViceVersa
Decimal to Binary Octal Hex & Vice Versa
BinarytoHEX&viceversa
Otherrepresentation
Signed,Unsigned,Complement
Operation
Add,Sub,Mul,Div,Mod
Howtohandlerealnumberefficiently?
Float,Double
Float Double
2
RomanSystem
Mayevolvestomakeeasytolookandfeel
Pre/PostConcept:(IV,V&VI)is(51,5&5+1)
BinarySystem,Others(Oct,Hex)
Onecancutanappleintotwo
pp
3
Significant Digits
SignificantDigits
Binary: 11101101
Binary:11101101
Most significant digit
MostsignificantdigitLeastsignificantdigit
Least significant digit
Decimal:
Decimal:
1063079
Binary (base 2)
Binary(base2)
Twodigits:0,1
Tomakethebinarynumbersmore
y
readable,thedigitsareoftenputingroups
of4
1010=1*23 +0*22 +1*21 +0*20
=8+2
= 10
=10
11001001=1*27 +1*26 +1*23 +1*20
=128
128 +64
64 +8
8 +1
1
=201
HowtoEncodeNumbers:Binary
Numbers
Workingwithbinarynumbers
Inbaseten,helpstoknowpowersof10
In base ten helps to know powers of 10
one,ten,hundred,thousand,tenthousand,...
Inbasetwo,helpstoknowpowersof2
I b
t
h l t k
f2
one,two,four,eight,sixteen,thirtytwo,sixty
f
four,onehundredtwentyeight
h d dt
t i ht
Countupbypowersoftwo
29
28
27
26
25
24
23
22
21
20
16
Octal (base 8)
Octal(base8)
Shorter&easiertoreadthanbinary
8digits:0,1,2,3,4,5,6,7,
Octalnumbers
Octal numbers
Counting
Decimal
Binary
Octal
Hexadecimal
00000
00001
00010
00011
00100
00101
00110
00111
01000
10
01001
11
10
01010
12
11
01011
13
12
01100
14
13
01101
15
14
01110
16
15
01111
17
16
10000
20
10
10
Fractional Number
FractionalNumber
Point:DecimalPoint,BinaryPoint,Hexadecimal
point
Decimal
247.75=2x102+4x101+7x100+7x101+5x102
Binary
10.101=1x21+0x20+1x21+0x22+1x23
Hexadecimal
6A.7D=6x161+10x160+7x161+Dx162
Successive
Division
Weighted
Multiplication
Octal8
01234567
Decimal10
0123456789
Weighted
M lti li ti
Successive Multiplication
Division
Successive Weighted
Di i i
Division
M lti li ti
Multiplication
Hexadecimal16
Binary2
0123456789ABCDEF
01
12
Decimal
Binary
DecimalBinary
Successive
Division
a)) Dividethedecimalnumberby2;theremainderistheLSBofthebinary
y ;
y
number.
b) Ifthequotationiszero,theconversioniscomplete.Otherwiserepeatstep
(a)usingthequotationasthedecimalnumber.Thenewremainderisthe
( )
g
q
nextmostsignificantbitofthebinary number.
Weighted
Multiplication
a) Multiplyeachbitofthebinary numberbyitscorrespondingbit
weightingfactor(i.e.,Bit020=1;Bit121=2;Bit222=4;etc).
b) Sumupalloftheproductsinstep (a)togetthedecimalnumber.
DecimaltoBinary:SubtractionMethod
y
Goal
Goodforhuman
Getthebinaryweightsto
adduptothedecimal
dd
t th d i l
quantity
=32
1
32 16
toomuch
a
=8
4
ok,keepgoing
=8+4=12
2
0 1 1 0 0
32 16
toomuch
=16
0 1 1
32 16
Workfromlefttoright
32 16 8
(Righttoleft mayfillin1s
0 0 1
thatshouldnthavebeen
32 16 8
there tryit).
0
DONE
answer
DecimaltoBinary:DivisionMethod
y
Goodforcomputer:Dividedecimalnumberby2and
insertremainderintonewbinarynumber.
y
Continuedividingquotientby2untilthequotientis0.
Example:Convertdecimalnumber12tobinary
12div2=(Quo=6,Rem=0)LSB
6div2=(Quo=3,Rem=0)
(
)
3div2=(Quo=1,Rem=1)
1 div 2 = ( Quo=0 Rem=1) MSB
1div2=(Quo=0,Rem=1)MSB
1210=1100
1 1 00 22
ConversionProcessDecimalBaseN
Successive
Division
a)) DividethedecimalnumberbyN;theremainderistheLSBoftheANY
y ;
BASENumber.
b) Ifthequotientiszero,theconversioniscomplete.Otherwiserepeat
step(a)usingthequotientasthedecimalnumber.Thenewremainder
p( )
g
q
isthenextmostsignificantbitoftheANYBASEnumber.
Weighted
Multiplication
a) MultiplyeachbitoftheANYBASEnumberbyitscorrespondingbit
weightingfactor(i.e.,Bit0N0;Bit1N1;Bit2N2;etc).
b) Sumupalloftheproductsinstep(a)togetthedecimalnumber.
r = 6 LSB
1
8 11
r =3
0
8 1
r = 1 MSB
9410 = 1368
17
r = E LSB
S
9410 = 5E16
r = 5 MSB
16
16
16
80
10
= 9010
5AH =1328
11
8 90
r = 2 LSB
1
8 11
r =3
0
8 1
r = 1 MSB
19
82
81
80
64
2
2
64 + 24 +
= 9010
2
2
2
45
90 r = 0 LSB
22
45 r = 1
11
22 r = 0
5
11 r = 1
2
5 r =1
1
2 r =0
0
1
r = 1 MSB
1328 =10110102
20
21
Substitution Code
SubstitutionCode
Convert010101101010111001101010
Convert
0101011010101110011010102 tohexusing
to hex using
the4bitsubstitutioncode:
0101 01101010111001101010
56AE6A16
Substitution Code
SubstitutionCode
Substitutioncodecanalsobeusedtoconvertbinaryto
octalbyusing3bitgroupings:
2
255271528
Other Representation
OtherRepresentation
Signed&UnsignedNumber
Signednumberlastbit(oneMSB)issignedbit
Si d
b l bi (
MSB) i i d bi
Assume:8bitnumber
Unsigned12:00001100
Signed+12:00001100
Signed12:10001100
Complementnumber
p
Unsignedbinary12=00001100
1ssComplementof12=1111
1
Complement of 12 = 1111 0011
24
Thanks
25