0% found this document useful (0 votes)
104 views17 pages

Floating Point Arithmetic

The document discusses floating-point arithmetic, including the representation of floating-point numbers and the four basic arithmetic operations of addition, subtraction, multiplication, and division. It also describes the steps involved in adding and subtracting floating-point numbers, potential difficulties that can arise, and provides an example algorithm for floating-point addition that equalizes exponents, adds the mantissas, and normalizes the result.

Uploaded by

Grace Reyes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views17 pages

Floating Point Arithmetic

The document discusses floating-point arithmetic, including the representation of floating-point numbers and the four basic arithmetic operations of addition, subtraction, multiplication, and division. It also describes the steps involved in adding and subtracting floating-point numbers, potential difficulties that can arise, and provides an example algorithm for floating-point addition that equalizes exponents, adds the mantissas, and normalizes the result.

Uploaded by

Grace Reyes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

Floating- Point Arithmetic

Mary Grace G. Reyes


Lets assume
Let
(XM, XE) be the floating point
representation of a number X,
Four Basic Arithmetic Operations for
Floating-Point Numbers (FIG4.40)
Addition

Subtraction ,

where
Multiplication

Division
Example: (Multiplication)
X=1.324001111017 Y=
1.04799245x1021
XY=
?
XY= (1.324001111.04799245)
10(17+21)
XY=
1.387586071038
Steps in adding/subtracting

1. Compute YE-XE , a fixed-point


subtraction
2. Shift XM by YE-XE places to the
right to form XM 2 XE-YE

3. Compute XM 2 YM, a fixed-


XE-YE

point addition or subtraction


Example: (Addition)
X=1.324001111017 Y=
1.04799245x1021X+Y=
XE-YE= 21- ?
Since XE<YE ,then
17=4 XM2-4=0.00013240
XM2-4
XM2-
4
+Y=0.00013240+1.0479924
X+Y= 1.04812485
Difficulties
1If biased exponents are added or subtracted using
fixed-point arithmetic in the course of a floating point
calculation, the resulting exponent is doubly biased
and must be corrected by subtracting the bias.
EXAMPLE:
Exponent Length= 4 Bias, 24-1 =8
XE =1111 +7 YE= 0101 -3
XE+YE= 10100 +20 , it denotes 12 in excess-8
code
10100-1000= 1100 +12, correct biased
Difficulties
2All-0 representation usually required of zero. The
resulting product has an all-0 mantissa but may not
have an all-0 exponent. A special step is needed to
make the exponent bits 0.

3A floating point operation causes overflow or


underflow if the result is too large or too small to be
represented. A floating point operation causes
overflow or underflow if the result is too large or too
small to be represented.
Difficulties
MANTISSA:
It is corrected by shifting the mantissa of the
result, and modifying the exponent. (Normalizing)
EXPONENT:
An error signal indicating floating point
overflow or underflow is generated.
An overflowed result may sometimes be
retained in denormalized form.
Floating Point Units

MANTISSA UNIT EXPONENT UNIT


Performs all four basic Simpler circuit for
operations on the adding, subtracting,
mantissas comparing exponents
Generic fixed point exponent comparison can
arithmetic circuit can be be done by a comparator
used or by subtracting the
exponents
Data path of a floating-point Arithmetic
unit
Figure 4.41
Exponent Unit Mantissa Unit

E1 E2 AC MQ DR

Adder
Adder

Data
Bus
Algorithm for floating point
addition (FIG4.42)
register AC[nM-1:0], DR[nM-1:0], E[nM-1:0], E1[nM-1:0],
E2[nM-1:0], AC_OVERFLOW[nM-1:0], ERROR[nM-1:0];
BEGIN: AC_OVERFLOW:= 0, ERROR:=0

LOAD: E1:=XE, AC:=XM;


E2:=YE, DR:=YM;

{Compare and Equalize Exponents}


COMPARE: E=E1-E2;
EQUALIZE: if E<0 then AC := right shift (AC), E := E+1,
go to EQUALIZE; else
If E>0 then DR:= right-shift(DR), E := E-1,
Algorithm for floating point
addition (FIG4.42)
{Add mantissas}
ADD: AC:= AC+DR, E:=max(E1,E2);

{Adjust for mantissa overflow and check for exponent overflow}


OVERFLOW: if AC_OVERFLOW = 1 then begin
If E=EMAX then go to ERROR;
AC := right-shift(AC), E := E+1, go to END; end
Algorithm for floating point
addition (FIG4.42)
{Adjust for zero result}
ZERO: if AC=0 then E:=0, go to END;
{Normalize result}
NORMALIZE: if AC is normalized then go to END;
UNDERFLOW: if E> EMIN then
AC:=left shift (AC), E:= E-1, go to
NORMALIZE;
{Set error flag indicating overflow or underflow}
ERROR: ERROR:=1;
END:
EXAMPLE: Addition

X= 0 01111111 1000000000000000000
Y= 0 10000111 0010101101000000000
X+Y= 0 10000111
00101100110000000000000
Illustration of Floating Point
addition algorithm (FIG4.43)

You might also like