Floating-Point Addition and Subtraction
5-33
Data Formats and Floating-Point Operation
Figure 5–17. Flowchart for Floating-Point Addition
α
(
man)
b(man)
α
(
exp)
b(exp)
(3)
(2)
Align mantissas
Subtract exponents
α
(
man) =
α
(
man) > > d
Discard LSBs to keep
α
(
man) in extended-
precision floating-
point format
d = b(exp)
±
α
(
exp)
c(man) = c(man) > > 1
c(exp) = c(exp) + 1
Discard LSBs to keep in
extended-precision
floating-point format
Test for special cases of
c(man)
c(exp) = –128
(6)
Overflow of
c(man)
(7)
k = # of leading
non-significant
sign bits
(5)
c(man) = 0
Test for special cases of
c(exp)
(12)
c(exp) underflow
(13)
c(exp) in range
(11)
c(exp) overflow
If
c(man) > 0,
set
c to most
positive value
If
c(man) < 0,
set
c to most
negative value
set
c to 0
c(exp) = –128
c(man) = 0
Set
c to final result
c =
α
+
b
(14)
(15)
(16)
(8)
(1)
Compare exponents
If
α
(
exp) < = b(exp)
c(exp)
=
b(exp)
else
c(exp)
=
α
(
exp)
(Assume for simplicity
that
α
(
exp) < = b(exp))
(4)
Add mantissas
c (man) =
α
(
man) + b(man)
c(man) < < k
c(exp) = c(exp) – k
(10)
(9)