Module 2
Module 2
module 2
By
Soumya Das
Asst prof. dept. of cse
GCE Kalahandi
Number Representation
Sign Magnitude
Sign magnitude is a very simple representation of negative numbers. In sign magnitude the first bit is
dedicated to represent the sign and hence it is called sign bit.
Sign bit ‘1’ represents negative sign.
Sign bit ‘0’ represents positive sign.
In sign magnitude representation of a n – bit number, the first bit will represent sign and rest n-1 bits
represent magnitude of number.
For example,
+25 = 011001
Where 11001 = 25
And 0 for ‘+’
-25 = 111001
Where 11001 = 25
And 1 for ‘-‘.
Range of number represented by sign magnitude method = -(2n-1-1) to +(2n-1-1) (for n bit number)
2’s complement method
Advantages –
The propagation delay is reduced.
It provides the fastest addition logic.
Disadvantages –
The Carry Look-ahead adder circuit gets
complicated as the number of variables increase.
The circuit is costlier as it involves more number of
hardware.
Booth algorithm
• Booth algorithm gives a procedure for multiplying binary integers in
signed 2’s complement representation in efficient way, i.e., less number
of additions/subtractions required. It operates on the fact that strings of
0’s in the multiplier require no addition but just shifting and a string of 1’s
in the multiplier from bit weight 2^k to weight 2^m can be treated as
2^(k+1 ) to 2^m.
• As in all multiplication schemes, booth algorithm requires examination of
the multiplier bits and shifting of the partial product. Prior to the shifting,
the multiplicand may be added to the partial product, subtracted from the
partial product, or left unchanged according to following rules:
• The multiplicand is subtracted from the partial product upon encountering
the first least significant 1 in a string of 1’s in the multiplier
• The multiplicand is added to the partial product upon encountering the
first 0 (provided that there was a previous ‘1’) in a string of 0’s in the
multiplier.
• The partial product does not change when the multiplier bit is identical to
the previous multiplier bit.
Booth algorithm contd.
• Example – A numerical example of
booth’s algorithm is shown below for n = 4.
It shows the step by step multiplication of -
5 and -7.
• MD = -5 = 1011, MD = 1011, MD'+1 = 0101 MR
= -7 = 1001
The explanation of first step is as
follows:
OPERATION AC MR QN+1 SC
0000 1001 0 4
AC + MD’ + 1 0101 1001 0
ASHR 0010 1100 1 3
AC + MR 1101 1100 1
ASHR 1110 1110 0 2
ASHR 1111 0111 0 1
AC + MD’ + 1 0010 0011 1 0
Normalization
• Floating point numbers are usually normalized
• Exponent is adjusted so that leading bit (MSB) of
mantissa is 1
• Since it is always 1 there is no need to store it
• Scientific notation where numbers are normalized to
give a single digit before the decimal point like in
decimal system e.g. 3.123 x 103
Floating point arithmatic
• A finite number can also represented by four
integers components, a sign (s), a base (b), a
significand (m), and an exponent (e). Then the
numerical value of the number is evaluated as
• (-1)s x m x be ________ Where m < |b|
• Depending on base and the number of bits used
to encode various components, the IEEE
754 standard defines five basic formats. Among
the five formats, the binary32 and the binary64
formats are single precision and double precision
formats respectively in which the base is 2.
IEEE Standard 754 Floating Point
Numbers
• The IEEE Standard for Floating-Point Arithmetic (IEEE 754) is a technical standard for floating-point
computation which was established in 1985 by the Institute of Electrical and Electronics Engineers
(IEEE). The standard addressed many problems found in the diverse floating point implementations
that made them difficult to use reliably and reduced their portability. IEEE Standard 754 floating
point is the most common representation today for real numbers on computers, including Intel-
based PC’s, Macs, and most Unix platforms.
• There are several ways to represent floating point number but IEEE 754 is the most efficient in most
cases. IEEE 754 has 3 basic components:
• The Sign of Mantissa –
This is as simple as the name. 0 represents a positive number while 1 represents a negative
number.
• The Biased exponent –
The exponent field needs to represent both positive and negative exponents. A bias is added to the
actual exponent in order to get the stored exponent.
• The Normalised Mantissa –
The mantissa is part of a number in scientific notation or a floating-point number, consisting of its
significant digits. Here we have only 2 digits, i.e. O and 1. So a normalised mantissa is one with only
one 1 to the left of the decimal.
• IEEE 754 numbers are divided into two based on the above three components: single precision
and double precision.
Table – 1 Precision Representation
Precision Base Sign Exponent Significand
Single 2 1 8 23+1
precision
Double 2 1 11 52+1
precision
Example
APPROXIMATE
DENORMALIZED NORMALIZED
DECIMAL
± approximately
± 2-149 to (1 – 2- ± 2-126 to (2 – 2- 10-44.85 to
Single Precision 23)×2-126 23)×2127 approximately
1038.53
± approximately
± 2-1074 to (1 – 2- ± 2-1022 to (2 – 2- 10-323.3 to
Double Precision 52)×2-1022 52)×21023 approximately
10308.
Floating point addition and subtraction
floating point addition
For example, we have to add 1.1 * 103 and 50.
We cannot add these numbers directly. First, we need to align
the exponent and then, we can add significand.
After aligning exponent, we get 50 = 0.05 * 103
Now adding significand, 0.05 + 1.1 = 1.15
So, finally we get (1.1 * 103 + 50) = 1.15 * 103
Here, notice that we shifted 50 and made it 0.05 to add these
numbers.