Professional Documents
Culture Documents
ANDMICROPROCESSORS
Computer Arithmetic
(Lecture - 10)
Dr.Sudip Roy
CourseWebsite:http://faculty.iitr.ac.in/~sudiproy.fcs/csn221_2015.html
PiazzaSite:https://piazza.com/iitr.ac.in/fall2015/csn221
RealNumbers:
Dr.SudipRoy
FloatingPointNumberFormats:
Thetermfloatingpointnumberreferstorepresentationofrealbinary
numbersincomputers
IEEE754standarddefinesstandardsforfloatingpointrepresentations
Generalformat
1.bbbbbtwo2eeee
or
Where
S=
F=
Dr.SudipRoy
E=
(1)S (1+F) 2E
sign,0forpositive,1fornegative
fraction(ormantissa)asabinaryinteger,1+Fiscalled
significand
exponent asabinaryinteger,positiveornegative(twos
complement)
MIPSSinglePrecision:
S E:8bitExponentF:23bitFraction
bit31
bits2330
bits022
127E128,Max|E|~128
Overflow:Exponentrequiringmorethan8bits.Numbercanbe
positiveornegative.
Underflow:Fractionrequiringmorethan23bits.Numbercanbe
positiveornegative.
MIPS:MicroprocessorwithoutInterlockedPipelineStages
Dr.SudipRoy
MIPSDoublePrecision:
S E:11bitExponentF:52bitFraction+
bit63
bits5262
bits3251
Continuationof52bitFraction
bits031
1023E1024,Max|E|~1024
Overflow:Exponentrequiringmorethan11bits.Numbercan
bepositiveornegative.
Underflow:Fractionrequiringmorethan52bits.Numbercan
bepositiveornegative.
Dr.SudipRoy
AlternativeRepresentationof4bitIntegers:
Dr.SudipRoy
IEEE754FloatingPointStandard:
Biasedexponent:trueexponentrange[127,128]ischangedto[0,255]:
Biasedexponent isan8bitpositivebinaryinteger.
Trueexponentobtainedbysubtracting127ten or01111111two
Firstbitofsignificandisalways1:
1.bbbb...b 2E
1beforethebinarypointisimplicitlyassumed.
Bias=2(k1) 1,ingeneral
Significandfieldrepresents23bitfractionafterthebinarypoint.
Significandrangeis[1,2),tobeexact[1,2 223]
Trueexponent=biasedexponent 127,for32bitrepresentation
Dr.SudipRoy
IEEE754FloatingPointStandard:
Dr.SudipRoy
ConversiontoDecimal:
Sign bit S
normalized E
bits 23-30
F
bits 0-22
1 10000001 01000000000000000000000
Signbitis1,numberisnegative
Biasedexponentis27+20=129
Thenumberis
(-1)S (1 + F) 2(exponent bias) =
=
=
=
Dr.SudipRoy
PositiveZeroinIEEE754:
0000000000000000000000000000000
Biased
exponent
Fraction
+1.0 2127
SmallestpositivenumberinsingleprecisionIEEE754standard.
Interpretedaspositivezero
Trueexponent lessthan126ispositiveunderflow;canberegardedas
zero.
Dr.SudipRoy
10
NegativeZeroinIEEE754:
1 0000000000000000000000000000000
Biased
exponent
Fraction
1.0 2127
SmallestnegativenumberinsingleprecisionIEEE754standard.
Interpretedasnegativezero.
Trueexponentlessthan126isnegativeunderflow;mayberegardedas0.
Dr.SudipRoy
11
PositiveInfinityinIEEE754:
0 11111111
Biased
exponent
00000000000000000000000
Fraction
+1.0 2128
LargestpositivenumberinsingleprecisionIEEE754standard.
Interpretedas+
Iftrueexponent=128andfrac on0,thenthenumberis
greaterthan.ItiscallednotanumberorNaN andmaybe
interpretedas
Dr.SudipRoy
12
NegativeInfinityinIEEE754:
1 1111111100000000000000000000000
Biased
exponent
Fraction
1.0 2128
SmallestnegativenumberinsingleprecisionIEEE754standard.
Interpretedas
Iftrueexponent=128andfrac on0,thenthenumberisless
than .ItiscallednotanumberorNaN andmaybe
interpretedas
Dr.SudipRoy
13
IEEE754FloatingPointStandard:
Positiveunderflow
Negativeunderflow
Negative
Overflow
+
Expressiblenegative
numbers
(2 223)2127
Dr.SudipRoy
2126
Expressiblepositive
numbers
2126
Positive
Overflow
(2 223)2127
14
FloatingPointArithmetic:
Dr.SudipRoy
15
FloatingPointAdditionandSubtraction:
0.
1.
2.
3.
4.
Zerocheck
Changethesignofsubtrahend,i.e.,convertto
summation
Ifeitheroperandis0,theotheristheresult
Significandalignment:rightshiftsignificandofsmaller
exponentuntiltwoexponentsmatch.
Addition:addsignificandsandreportexceptionifoverflow
occurs.Ifsignificand=0,returnresultas0.
Normalization
Shiftsignificandbitstonormalize.
reportoverfloworunderflowifexponentgoesoutof
range.
Rounding
Dr.SudipRoy
16
Example(4SignificantFractionBits):
Subtraction:0.5ten 0.4375ten
Step0:
Floatingpointnumberstobeadded
1.000two 21 and1.110two 22
Step1:
Significand oflesserexponentisshifted
rightuntilexponentsmatch
1.110two 22 0.111two 21
Step2:
Addsignificands,1.000two+( 0.111two)
Resultis0.001two 21
01000
+11001
00001
2scomplementaddition,onebitaddedforsign
Dr.SudipRoy
17
Example(Continued):
Step3:
Step4:
Dr.SudipRoy
Normalize,1.000two 2 4
Nooverflow/underflowsince
127exponent126
Rounding,nochangesincethesumfitsin4bits.
1.000two 2 4=(1+0)/16=0.0625ten
18
FloatingPointMultiplication(BasicIdea):
1.
2.
3.
4.
5.
Dr.SudipRoy
Separatesign
Addexponents
Multiplysignificands
Normalize,round,checkoverflow/underflow
Replacesign
19
FloatingPointMultiplication(Example):
Multiply0.5ten and 0.4375ten
(answer= 0.21875ten)or
Multiply1.000two21 and1.110two22
Step1:Addexponents
1+(2)= 3
Step2:Multiplysignificands
1.000
1.110
0000
1000
1000
1000
1110000
Productis1.110000
Dr.SudipRoy
20
FloatingPointMultiplication(Example):
Step3:
Normalization:Ifnecessary,shiftsignificand rightand
incrementexponent.
Normalizedproductis1.110000 23
Checkoverflow/underflow:127exponent126
Step4:Rounding:1.110 23
Step5:Sign:Operandshaveoppositesigns,
Productis1.110 23
(Decimalvalue= (1+0.5+0.25)/8= 0.21875ten)
Dr.SudipRoy
21
FloatingPointAdditionandSubtractionFlowchart:
Dr.SudipRoy
22
FloatingPointMultiplicationFlowchart:
Dr.SudipRoy
23
Dr.SudipRoy
24