Professional Documents
Culture Documents
WINSEM2023-24 BCSE205L TH VL2023240500843 2024-02-02 Reference-Material-I
WINSEM2023-24 BCSE205L TH VL2023240500843 2024-02-02 Reference-Material-I
Dr. P.Keerthika
Associate Professor
School of Computer Science and Engineering
Vellore Institute of Technology, Vellore
Number System & Types
• In digital electronics, the number
system is used for representing the
information.
• Number system - different bases
• The base or radix of the number
system is the total number of the
digit used in the number system.
Binary Number Systems
• Characteristics
• It holds only two values, i.e., either 0 or 1.
• It is also known as the base 2 number system.
• The position of a digit represents the 0 power of
the base(2). Example: 20
• The position of the last digit represents the x
power of the base(2). Example: 2x, where x
represents the last position.
• Examples: (10100)2, (11011)2, (11001)2, (000101)2,
Binary Number Systems
• Terminologies - Binary systems
• Each digit – 1 Bit – 0/1 - Single Binary Digit
• Collection of 4 bits - Nibble
• Collection of 8 bits - Byte
• Collection of 16/32/64 bits - Word
Depends on Memory
Organization of a
Computer
Decimal Number Systems
• Contains ten digits from 0 to 9
• base 10 number system
• The successive place value or position, left
to the decimal point holds units, tens,
hundreds, thousands, and so on.
Octal Number Systems
• Contains Eight digits from 0 to 7
• base 8 number system
• Octal number – represented in only 3 bits.
• The position of a digit represents the 0
power of the base(8). Example: 80
• The position of the last digit represents the
x power of the base(8). Example: 8x, where
x represents the last position.
• Examples:
(273)8, (5644)8, (0.5365)8, (1123)8, (1223)8.
Hexadecimal Number Systems
• Contains ten digits from 0 to 9 and 6 letters from A to
F.
• The letters from A to F defines numbers from 10 to 15.
• base 16 number system.
• The position of a digit represents the 0 power of the
base(16). Example: 160
• The position of the last digit represents the x power of
the base(16). Example: 16x, where x represents the
last position.
• Examples: (FAC2)16, (564)16, (0ABD5)16, (1123)16, (11F3)16.
Number Systems
• Numbers
• Unsigned Numbers (+)
• has only magnitude - no sign.
• Signed Numbers(+/-)
• has both magnitude and sign
• Sign bit – 0 – positive number
• Sign bit – 1 – Negative number
• Representing Binary Numbers
• n bits – can be used to represent--- 2n distinct numbers (0 to 2n-1)
For example: If n=3 bits, 23 = 8 distinct numbers (0 to 7)can be represented
(0-000, 1-001, 2-010, 3-011, 4-100, 5-101, 6-110, 7-111)
Unsigned Number Representation of 4 Bits
• If no. of bits 4, Unsigned 0 to 2n-1
• then for unsigned numbers, these four bits can store the decimal values from
0 to 24-1 (decimal values 0 to 15).
No. of Unsigned numbers that can be stored in
bits (n) n bit representation
3 Decimal Numbers 0 to 7 0 to 23-1
4 D. Numbers 0 to 15 0 to 24-1
5 D. Numbers 0 to 32 0 to 25-1
6 D. Numbers 0 to 63 0 to 26-1
7 D. Numbers 0 to 127 0 to 27-1
8 D. Numbers 0 to 255 0 to 28-1
……. …… ……
Unsigned 0 to 2n-1
Signed (Sign Magnitude Representation)-2n-1+1 to 2n-1-1
Signed (One’s Complement Representation)-2n-1+1 to 2n-1-1
Signed (Two’s Complement Representation)-2n-1 to 2n-1-1
Sign Magnitude Representation of 4 Bits
Sign-Magnitude Representation
Advantages Expansion of Bit Length: Add additional bit positions to the left
• Unique representation of 0. and fill in with the value of the original sign bit.
• Subtraction can be done using addition. Overflow Rule: If two numbers with the same sign (both positive or
• Leads to substantial saving in circuitry. both negative) are added, then overflow occurs if and only if the
result has the opposite sign.
Features of Two’s complement
Features of Two’s complement
To conclude: Pros and cons of integer representation
• Signed magnitude representation:
• 2 representations for 0
• Simple
• 255 different numbers can be represented.
• Need to consider both sign and magnitude in arithmetic
• Different logic for addition and subtraction
• 1’s complement representation:
• 2 representations for 0
• Complexity in performing addition and subtraction
• 255 different numbers can be represented.
• 2’s complement representation:
• Only one representation for 0
• 256 different numbers can be represented.
• Arithmetic works easily
To Conclude: Signed Binary Numbers
-9 +9
Signed magnitude representation 1 1001 0 1001
Signed 1’s complement representation 1 0110 0 1001
Signed 2’s complement representation 1 0111 0 1001
-0 +0
Signed magnitude representation 1 0000 0 0000
Signed 1’s complement representation 1 1111 0 0000
Signed 2’s complement representation -None- 0 0000
To Conclude: Range of Binary Numbers
0+4+1= 5
• 5 is the unsigned decimal value of the binary number 0101
Binary to Decimal Conversion (Unsigned)
Sign bit
– Hence multiply by –(27)
Signed Binary Number Arithmetic
• Add or Subtract two signed binary number including its sign bit
• The 1’s complement and 2’s complement rules of general binary number – applicable
So, very first step - to decide on the number of bits to represent number
Real/Fractional Number Notation
• Real Numbers - numbers with fractional component
• Two major approaches to store real numbers
• Fixed Point Notation
• Floating Point Notation.
• Fixed point notation - there are a fixed number of digits after the decimal
point (Integer . Fraction)
• In this representation the position of the radix point is fixed. Hence this
representation is called fixed point representation
• Example: (123.431), (4.5)10 = (100.1)2
• Floating point number - allows for a varying number of digits after the
decimal point. (Integer . Fraction)
• In this representation the position of the radix point is allowed to move.
• Example: (-123.334444455555567),
Real Number Notation
Fixed Point Representation
• The number of integer and fraction bits must be agreed upon by
those generating and those reading the number
• Example: Fixed-point representation of 6.75 using 4 integer bits
and 4 fraction bits in binary
• 6 =110 - 0110
• .75 = 110 1100
• Binary Representation:
01101100
(6.75)10 = (0110.1100)2
• Convert back to Decimal (Check)
0*23 + 1*22 + 1*21 + 0*20 + 1*2-1 + 1*2-2 + 0*2-3 + 0*2-4
= 6.75
Fixed Point Representation
Fixed Point Representation (unsigned)
Fixed Point Representation (Signed)
Fixed Point Binary Numbers - Arithmetic
Operations
• Addition
• Subtraction
• Multiplication
• Division
Fixed Point Binary Numbers - Addition
• Follow same rules as in decimal addition, with the difference that when
sum is 2 indicates a carry (not a 10)
• Carry rules Carry 1 1 1 1 1 0
• 0+0 = sum 0 carry 0 Augend 0 0 1 0 0 1
• 0+1 = 1+0 = sum 1carry 0 Addend 0 1 1 1 1 1
• 1+1 = sum 0 carry1 Result 1 0 1 0 0 0
• 1+1+1 = sum 1 carry1
carry and
carry generated, overflow
but no overflow The answer must be -9 (which needs
5 bits and cannot be represented with
4 bits). Hence the answer calculated
shows +7 (Because of overflow)
no carry and
no carry and overflow
no overflow
Overflow
• Overflow and Underflow – Errors
• To check for Overflow error - need a simple error-detection method that doesn't
require any additional arithmetic.
• the most elegant solution is to check for the sign of the sum and compare it against the signs
of the numbers added.
• Obviously, two positive numbers added together should give a positive result, and two negative numbers
added together should give a negative result.
• Notice that whenever we had a condition of overflow in the example problems, the sign of the result was
always opposite of the two added numbers: +1710 plus +1910 giving -2810, or -1710 plus -1910 giving +2810.
• By checking the signs alone we are able to tell that something is wrong.
• But what about cases where a positive number is added to a negative number? What sign should the
sum be in order to be correct. Or, more precisely, what sign of sum would necessarily indicate an
overflow error?
• There will never be an overflow error when two numbers of opposite signs are added together!
• The reason for this is apparent when the nature of overflow is considered. Overflow occurs when the magnitude
of a number exceeds the range allowed by the size of the bit field. The sum of two identically-signed numbers
may very well exceed the range of the bit field of those two numbers, and so in this case overflow is a possibility.
However, if a positive number is added to a negative number, the sum will always be closer to zero than either of
the two added numbers: its magnitude must be less than the magnitude of either original number, and so
overflow is impossible.
Fixed Point Arithmetic Operations-
Multiplication
Fixed Point Binary Numbers -
Multiplication
• Multiplication
• Generation of Partial Products.
• Each successive partial product is shifted one position to the left relative to
the preceding partial product
• Final product = sum of the Partial Products.
• Multiplication of two unsigned binary numbers of n bit size results into 2n bit
result.
N * N bits input = 2N bits result
Fixed Point Binary Numbers -
Multiplication
Unsigned Integer representation
• n bit - How many distinct numbers can be represented?
• 2n – Distinct numbers.
For example:
If n=3 bits,
23 = 8 (0-000, 1-001, 2-010, 3-011, 4-100, 5-101, 6-110, 7-111)
0 is minimum and 7 (2n-1) is maximum
If n=4 bits,
24 = 16 (0 to 15)
0 is minimum and 15 is maximum
If n=5 bits,
25 = 32 (0 to 31)
0 is minimum and 31 is maximum
If n=6 bits,
26 = 64 (0 to 63)
0 is minimum and 63 is maximum
Multiplication of unsigned numbers
1. Multiply the given numbers 13 x 11
• number of bits required to represent the number 13 is 4 bits
• number of bits required to represent the number 11 is 4 bits
• Convert decimal to binary
• 13 1101
• 111011
Multiplication of unsigned numbers
1. Multiply the given numbers 13 x 11
27 26 25 24 23 22 21 20
Multiplicand is shifted by
displacing it through an
array of adders.
Multiplication of Signed numbers
Signed number representation
• For an n bit representation: MSB- sign bit(0 or 1), n-1(magnitude)
0 0 0 0 0 1 1 0 1
Sign extension is
shown in red
0 0 0 0 0 0 0 0
0 0 0 1 1 0 1
0 0 0 0 0 0
0 0 1 0 0 0 1 1 1 1 - 143
- 29 28 27 26 25 24 23 22 21 20
= (0*-29)+ (0*28)+ (1*27)+(0*26)+(0*25)+(0*24)+(1*23)+(1*22)+(1*21)+(1*20)
=128+8+4+2+1 =143 answer
Multiplication of Signed numbers
• Case 2: Multiply the given numbers (-13) x (+11) (Positive Multiplier)
1 1 1 1 1 1 0 0 1 1
1 1 1 1 1 0 0 1 1
Sign extension is
0 0 0 0 0 0 0 0 shown in red
1 1 1 0 0 1 1
0 0 0 0 0 0
1 1 0 1 1 1 0 0 0 1 - 143
- 29 28 27 26 25 24 23 22 21 20
= (1*-29)+ (1*28)+ (0*27)+(1*26)+(1*25)+(1*24)+(0*23)+(0*22)+(0*21)+(1*20)
=-512+256+64+32+16+1
=-143 answer
Multiplication of Signed numbers
• Case 3: Multiply the given numbers (+13) x (-11) (Negative Multiplier)
• number of bits required to represent the number +13 is 5 bits
• number of bits required to represent the number -11 is 5 bits
• Convert decimal to binary
• 13 1101 111011
• Take 2’s complement of 110100+1=0101
• +13 01101(5 bits=0(sign), 1101(magnitude))
• -1110101(5 bits=1(sign), 0101(magnitude))
• Since the multiplier is negative(-), take 2’s complement of both M(+13) and Q(-11)
and proceed as -13 and 11
• Take 2’s complement of (+13)10010+1=10011(-13)
• Take 2’s complement of (-11)01010+1=01011(11)
• -13 10011(5 bits=1(sign), 0011(magnitude))
• +1101011(5 bits=0(sign), 1011(magnitude))
Multiplication of Signed numbers
Since the multiplier is negative(-), take 2’s complement of
both M(+13) and Q(-11) and proceed as -13 and 11
1 0 0 1 1 - 13
0 1 0 1 1 ( + 11 )
1 1 1 1 1 1 0 0 1 1
1 1 1 1 1 0 0 1 1
Sign extension is
0 0 0 0 0 0 0 0 shown in red
1 1 1 0 0 1 1
0 0 0 0 0 0
1 1 0 1 1 1 0 0 0 1 - 143
- 29 28 27 26 25 24 23 22 21 20
= (1*-29)+ (1*28)+ (0*27)+(1*26)+(1*25)+(1*24)+(0*23)+(0*22)+(0*21)+(1*20)
=-512+256+64+32+16+1
=-143 answer
Multiplication of Signed numbers
• Case 4: Multiply the given numbers (-13) x (-11)
• number of bits required to represent the number -13 is 5 bits
• number of bits required to represent the number -11 is 5 bits
• Convert decimal to binary
• 13 1101 111011
• Take 2’s complement of 130010+1=0011
• Take 2’s complement of 110100+1=0101
• -13 10011(5 bits=1(sign), 0011(magnitude))
• -1110101(5 bits=1(sign), 0101(magnitude))
• Since the multiplier is negative(-), take 2’s complement of both M(-13) and Q(-11) and
proceed as 13 and 11
• Take 2’s complement of (-13)01100+1=01101(+13)
• Take 2’s complement of (-11)01010+1=01011(+11)
• +13 01101(5 bits=0(sign), 1101(magnitude))
• +1101011(5 bits=0(sign), 1011(magnitude))
Multiplication of Signed numbers
0 1 1 0 1 + 13
0 1 0 1 1 ( + 11 )
0 0 0 0 0 0 1 1 0 1
0 0 0 0 0 1 1 0 1
Sign extension is
shown in red
0 0 0 0 0 0 0 0
0 0 0 1 1 0 1
0 0 0 0 0 0
0 0 1 0 0 0 1 1 1 1 - 143
- 29 28 27 26 25 24 23 22 21 20
= (0*-29)+ (0*28)+ (1*27)+(0*26)+(0*25)+(0*24)+(1*23)+(1*22)+(1*21)+(1*20)
=128+8+4+2+1 =143 answer
Multiplication of Signed numbers
1 0 0 0 0 0 0 1 1 0 Initial 4
2 1 0 0 1 0 0 1 1 0 AA-M
1 1 0 0 1 0 0 1 1 Right Shift 3
3 1 1 1 0 0 1 0 0 1 Right Shift 2
4 0 1 0 1 0 1 0 0 1 AA+M
0 0 1 0 1 0 1 0 0 Right Shift 1
1 0 0 0 0 1 1 0 1 0 Initial 4
A0 0 0 0
2 1 0 0 1 1 1 0 1 0 AA-M -M 1 0 0 1
1 1 0 0 1 1 1 0 1 Shift 3 A1 0 0 1
3 0 0 1 1 1 1 1 0 1 AA+M A1 1 0 0
+M 0 1 1 1
0 0 0 1 1 1 1 1 0 Shift 2
A 10 0 1 1 Discard 1
4 1 0 1 0 1 1 1 1 0 AA+M A0 0 0 1
1 1 0 1 0 1 1 1 1 Shift 1 -M 1 0 0 1
A1 0 1 0
5 1 1 1 0 1 0 1 1 1 Shift 0
-27 26 25 24 23 22 21 20 Convert binary to decimal and the
answer is -21
Example: Multiplication of Signed numbers - Booth Algorithm
Multiply -7 x 3
Multiplicand =-7 Binary equivalent is 1001M
Multiplier = 3 Binary equivalent is 0011Q
1 0 0 0 0 0 0 1 1 0 Initial 4
A0 0 0 0
2 0 1 1 1 0 0 1 1 0 AA-M -M 0 1 1 1
0 0 1 1 1 0 0 1 1 Shift 3 A0 1 1 1
3 0 0 0 1 1 1 0 0 1 Shift 2 A0 0 0 1
+M 1 0 0 1
4 1 0 1 0 1 1 0 0 1 AA+M A1 0 1 0
1 1 0 1 0 1 1 0 0 Shift 1
5 1 1 1 0 1 0 1 1 0 Shift 0
1 0 0 0 0 1 1 0 1 0 Initial 4
A0 0 0 0
2 0 1 1 1 1 1 0 1 0 AA-M -M 0 1 1 1
0 0 1 1 1 1 1 0 1 Shift 3 A0 1 1 1
3 1 1 0 0 1 1 1 0 1 AA+M A0 0 1 1
+M 1 0 0 1
1 1 1 0 0 1 1 1 0 Shift 2
A1 1 0 0
4 0 1 0 1 0 1 1 1 0 AA-M
A1 1 1 0
0 0 1 0 1 0 1 1 1 Shift 1 -M 0 1 1 1
A0 1 0 1 Discard 1
5 0 0 0 1 0 1 0 1 1 Shift 0
-27 26 25 24 23 22 21 20 Convert binary to decimal and the
answer is 21
Multiplication of Signed numbers
– Booth Algorithm
Practice Problems
• Show the step by step multiplication process using Booth
algorithm when the following binary numbers are
multiplied. Assume 5-bit registers that hold signed
numbers. The multiplicand in both cases is +15.
• (+15) × (+13)
• (+15) × (-13)
Multiplication of Signed numbers
– Bit Pair Recoding Algorithm
• Fast Multiplication / Modified Booth Algorithm
• Bit-pair recoding halves the maximum number of summands (versions of the
multiplicand)
• - Reduces the number of Partial Products
Multiplication of Signed numbers
– Bit Pair Recoding Algorithm
Multiplier Multiplier bit Booth
Note:
on the right Multiplier Bit
Bit i+1 Bit (i)
If multiplier bit is (left bit) (Bit to modify) i-1
Implied 0 0 0 0 0×M
0 0 0 1 1 0 0 0 0 1 +1 × M
Sign extension 0 +2 -2Bit Pair Recoding Multiplier 0 1 0 +1 × M
0
0
1 1
+2
0 1
-2
0 1 1 +2 × M
1
0
1
0
1
0
1
1
1
1
0
0
0
1
1
0
1 0
1 0 0 -2 × M
0 0 0 0 0 0
1 0 0 0 1 0 0 1 1 1 0
1 0 1 -1 × M
1 1 0 -1 × M
64+8+4+2=78
1 1 1 0× M
Multiplication of Signed numbers – Bit Pair Recoding Algorithm
Case 2: 13 x -6
0 1 1 0 1 ( + 13 )
1 1 0 1 0 -6
Multiplier Multiplier Booth
Bit i+1 Bit (i) bit on the Multiplier
• Bit- Pair Recoded Multiplier (left bit) (Bit to right Bit
Implied 0 modify) i-1
1 1 1 0 1 0 0
0 0 0 0×M
Sign extension 0 -1 -2 Bit Pair Recoding Multiplier 0 0 1 +1 × M
0 1 1 0 1 0 1 0 +1 × M
0 -1 -2
1 1 1 1 1 0 0 1 1 0 0 1 1 +2 × M
1 1 1 1 0 0 1 1
0 0 0 0 0 0 1 0 0 -2 × M
1 1 1 0 1 1 0 0 1 0 -78
- 29 28 27 26 25 24 23 22 21 20 1 0 1 -1 × M
= (1*-29)+ (1*28)+ (1*27)+(0*26)+(1*25)+(1*24)+(0*23)+(0*22)+(1*21)+(0*20) 1 1 0 -1 × M
=-512+256+128+32+16+2
=-78 answer 1 1 1 0× M
Multiplication of Signed numbers – Bit Pair Recoding Algorithm
Case 3: -13 x 6
1 0 0 1 1 ( - 13 )
0 0 1 1 0 +6
Multiplier Multiplier Booth
Bit i+1 Bit (i) bit on the Multiplier
• Bit- Pair Recoded Multiplier (left bit) (Bit to right Bit
modify) i-1
Implied 0
0 0 0 1 1 0 0 0 0 0 0×M
Sign extension 0 +2 -2Bit Pair Recoding Multiplier 0 0 1 +1 × M
1 0 0 1 1
0 +2 -2 0 1 0 +1 × M
0 0 0 0 0 1 1 0 1 0 0 1 1 +2 × M
1 1 1 0 0 1 1 0
0 0 0 0 0 0 1 0 0 -2 × M
-78
1 1 1 0 1 1 0 0 1 0
1 0 1 -1 × M
- 29 28 27 26 25 24 23 22 21 20
1 1 0 -1 × M
=-512+256+128+32+16+2 =-78 answer
1 1 1 0× M
Multiplication of Signed numbers – Bit Pair Recoding Algorithm
Case 4: -13 x -6
1 0 0 1 1 ( - 13 )
1 1 0 1 0 -6
Multiplier Multiplier Booth
Bit i+1 Bit (i) bit on the Multiplier
• Bit- Pair Recoded Multiplier (left bit) (Bit to right Bit
Implied 0 modify) i-1
1 1 1 0 1 0 0
0 0 0 0×M
Sign extension 0 -1 -2 Bit Pair Recoding Multiplier 0 0 1 +1 × M
1 0 0 1 1
0 1 0 +1 × M
0 -1 -2
0 1 1 +2 × M
0 0 0 0 0 1 1 0 1 0
0 0 0 0 1 1 0 1
1 0 0 -2 × M
0 0 0 0 0 0 1 0 1 -1 × M
0 0 0 1 0 0 1 1 1 0 64+8+4+2=78 1 1 0 -1 × M
- 29 28 27 26 25 24 23 22 21 20
1 1 1 0× M
Multiplication of Signed numbers
– Bit Pair Recoding Algorithm
Practice Problems
• Show the step by step multiplication process using Bit-pair
recoding technique when the following binary numbers are
multiplied. Assume 5-bit registers that hold signed
numbers. The multiplicand in both cases is +15.
• (+15) × (+13)
• (+15) × (-13)
Fixed Point Arithmetic Operations-
Division
Division
• First, the bits of the dividend are examined from left to right, until the
set of bits examined represents a number greater than or equal to the
divisor
• this is referred to as the divisor being able to divide the number
• Until this event occurs, 0s are placed in the quotient from left to right
• When the event occurs, a 1 is placed in the quotient and the divisor is
subtracted from the partial dividend
• The result is referred to as a partial remainder
Binary Division - Example
Circuit Arrangement
Hardware Implementation of binary division
• If the sign of A is 1,
• Shift A and Q left one binary position
set q0 to 0 and
A+M A (restore A);
Otherwise,
set q0 to 1 , No ADD (No Restore);
• Repeat these steps n times
Restoring Division – Example 1
Dividend = 8 Divisor = 3 • Shift A and Q left one binary position
• A-M A (Subtract M from A and place the result back in A)
• If the sign of A is 1,
set q0 to 0 and
A+M A (restore A);
Otherwise,
set q0 to 1 , No ADD (No Restore);
• Repeat these steps n times
Restoring Division – Example 2
• Q (Dividend) = 7 and M (Divisor)= 3
Non - Restoring Division
• Avoids restoring step in every cycle – improves the performance
• Drawbacks of Restoring Division
• In restoring,
if A is +ve (0),
left shift, A-M ----- 2A-M
if A is –ve (1),
A+M, Left Shift, A-M ------------- 2(A+M)-M =2A+M
Non - Restoring Division - Steps
If the sign of A is 1,
Shift A and Q left one binary position (Left Shift),
A+M A;
Otherwise,
n cycles Shift A and Q left one binary position (Left Shift),
A-M A;
If the sign of A is 1,
set q0 to 0
Otherwise,
set q0 to 1,
Repeat these steps n times
After n cycles,
If the sign of A is 1,
A+M A; (Restore)
Non - Restoring Division – Example 1
Dividend = 8 Divisor = 3
If the sign of A is 1,
Shift A and Q left one binary position (Left Shift),
A+M A;
Otherwise,
n cycles Shift A and Q left one binary position (Left Shift),
A-M A;
If the sign of A is 1,
set q0 to 0
Otherwise,
set q0 to 1,
Repeat these steps n times
After n cycles,
If the sign of A is 1,
A+M A; (Restore)
Restoring Division – Examples
Case 1: Dividend = 12 Divisor = 3
Restoring Division – Examples
Case 1: Dividend = 12 Divisor = 3
Restoring Division – Examples
Case 2: Dividend = -7 Divisor = 3
• Dividend = -ve
• Divisor = +ve
• Algorithm:
Restoring Division – Examples
Case 3: Dividend = 7 Divisor = -3
Case 4: Dividend = -7 Divisor = -3
Restoring Division – Examples
• Perform Division using Restoring and Non - Restoring Algorithm.
Dividend = 11 Divisor = 2
0 - positive number
1 - negative number
• Biased exponent
- An 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.
• Normalized Mantissa
- Mantissa - part of a number in scientific notation or a floating-point number
- consists of its significant digits.
- Here we have only 2 digits, i.e. O and 1.
- So a normalized mantissa is one with only one ‘1’ to the left of the decimal.
Floating Point Representation
IEEE-754 Floating Point Representation
Excess 8 format
Floating Point Representation – Examples
negative
20 127 + 20 = 147
negative
...
stored [23 bits]
– 6 + 127 = 13310 1 · 0 0 1 1 0 1 1 0 1 1 0 ...
1 1 0 0 0 0 1 0 1 0 0 1 1 0 1 1 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
sign biased exponent significand
Floating Point Representation - Example
• Represent 85.125 in Floating Point Single Precision Format
• Steps: 3. Identify Sign bit
1. Binary Conversion sign = 0
85 = 1010101, 0.125 = 001
85.125 = 1010101.001 4. Find the Exponent with Bias Value
Biased exponent for Single precision :
2. Normalize the Mantissa Excess 127+6=133
1.010101001 x 26 Exponent = 133 = 10000101
Normalized Mantisa = 010101001
(add 0's to complete the 23 bits) E-127=6
E=133
The IEEE 754 Single precision is: Exponent = 133 = 10000101
0 10000101 01010100100000000000000
Floating Point Representation - Example
• Represent 85.125 in Floating Point Double Precision Format
• Steps: 3. Identify Sign bit
1. Binary Conversion sign = 0
85 = 1010101, 0.125 = 001
85.125 = 1010101.001 4. Find the Exponent with Bias Value
Biased exponent for Double precision :
2. Normalize the Mantissa Excess 1023+6 =1029
1.010101001 x 26 Exponent = 1029 = 10000000101
Normalized Mantisa = 010101001
(add 0's to complete the 52 bits) E-1023=6
E=1029
The IEEE 754 Double precision is: Exponent = 1029 = 10000000101
0 10000000101 0101010010000000000000000000000000000000000000000000
Floating Point Representation - Example
• Represent 1259.125 in Floating Point Single Precision Format
• Step1: Convert to Binary Step 2: Normalize the Mantissa
Floating Point Representation - Example
• Represent 1259.125 in Floating Point Single Precision Format
• SP format (Excess-127) DP format (Excess-1023)
Conversion of Floating Point Binary
Representation to Decimal- Example
Convert 0110100000000011 to FP Decimal. (Assume M=9 bits, E=6 bits) in the form S.M.E
(Assume Exponent is not Biased and Mantissa is not normalized)
Conversion of Floating Point Binary
Representation to Decimal- Example
Convert 0110100000000011 to FP Decimal. (Assume M=9 bits, E=6 bits) in the form S.M.E
(Assume Exponent is not Biased and Mantissa is not normalized)
Steps:
1. Convert E to decimal.
2. Place the radix point in Mantissa based on
the decimal Exponent (E).
(If 23 – place radix point after first 3 bits.
Neglect the sign bit)
3. Follow Binary to Decimal Procedure.
Conversion of Floating Point Binary
Representation to Decimal- Example
Convert 0101010000000010 to FP Decimal. (Assume M=9 bits, E=6 bits) in the form S.M.E
(Assume Exponent is not Biased and Mantissa is not normalized)
Floating Point Representation
• Overflow generally means that
values have grown too large to be
represented.
• Underflow is a less serious
problem because is just denotes a
loss of precision, which is
guaranteed to be closely
approximated by zero.
Exercise Problems
Express the number - (640.5)10 in IEEE 32 bit and 64 bit floating point format
Solution:
• IEEE 32 BIT FLOATING POINT FORMAT
MSB 8 bits 23 bits
sign Biased Mantissa/Significand
Exponent (Normalized)
Step 1: Express the given number in binary form
(640.5) = 1010000000.1* 20
Step 2: Normalize the number into the form 1.bbbbbbb
1010000000.1* 20 = 1. 0100000001* 29
Once Normalized, every number will have 1 at the leftmost bit. So IEEE notation is saying that there is no need to store
this bit. Therefore significand to be stored is 0100 0000 0100 0000 0000 000 in the allotted 23 bits
Exercise Problems
Express the number - (640.5)10 in IEEE 32 bit and 64 bit floating point format
Solution:
• IEEE 32 BIT FLOATING POINT FORMAT
MSB 8 bits 23 bits
sign Biased Mantissa/Significand
Exponent (Normalized)
Step 3: For the 11 bit biased exponent field, the bias used is
2k-1-1 = 28-1-1 = 127
Add the bias 127 to the exponent 9 and convert it into binary in order to store for 8-bit biased
exponent. 127 + 9 =136 ( 1000 1000)
1 1000 0001 000 0100 0000 0010 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
Exercise Problems
Represent -12.62510 in single precision IEEE-754 format.
Solution:
• Step #1: Convert to target base. -12.62510 = -1100.1012
• Step #2: Normalize. -1100.1012 = -1.1001012 × 23
• Step #3: Fill in bit fields. Sign is negative, so sign bit is 1.
Exponent is in excess 127 (not excess 128!), so exponent is represented as the
unsigned integer E = 3 + 127 = 130.
Leading 1 of significant is hidden, so final bit pattern is:
1 1000 0010 . 1001 0100 0000 0000 0000 000
Floating Point Arithmetic Operations
Addition
Subtraction
Multiplication
Division
Floating Point Arithmetic Operations
• Note:
• Sign Bit – Not considered for Calculations
• IEEE 754 format is optional
• Biasing the exponent - Optional
• Normal Floating point Operations is performed
• Floating Point Operations: – No 2’s complement (Sign bit is
represented Directly…)
• Addition – Directly Add mantissas (No 2’s Complement)
• Subtraction – Directly subtract Mantissas (No 2’s Complement)
• Multiplication Division – Direct multiplication (No 2’s Complement)
• Division – Direct Division (No 2’s Complement)
Floating Point Arithmetic Operations
• Normal Addition
X = 1.01101 x 27 1.01101 x 27
Y = 1.10101 x 26 + 0.110101 x 27
• Normal Subtraction 10.001111 x 27
X = 1.01101 x 27 1.01101 x 27
Y = 1.10101 x 26 – 0.110101 x 27
0.100101 x 27
• Normal Multiplication
X = 6.2510 = 110.012 = 1.1001 x 22 1.10012
Y = 12.510 = 1100.12 = 1.1001 x 23 x 1.10012
10.011100012
• Normal Division
X = 3.7510 = 11.112 = 1.111 x 21 0.110011
1.111 1.011111101
Y = 95.62510 = 101 1111.1012
= 1.011111101 x 26
Floating Point Arithmetic Operations –
Addition/Subtraction
0.0234 Not normalized
• Steps 0.234×10-1 -- Normalized
• Check for 0’s in the given decimal and normalize it. (If the MSB bit is Non-zero –> Normalized)
No 2’s Complement
Direct Addition
= 273.125
Floating Point Arithmetic Operations –
Addition - Example
Floating Point Arithmetic Operations –
Subtraction - Example Normalize
No 2’s Complement
Direct Subtraction
...
only 24 bits can be stored
1 0 0 0 1 0 0 0 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1
32-bit register
more than half
+1 of the LSB
167
Floating Point Arithmetic Operations –
Addition – in IEEE format
12.210 = 1100.0011 0011 ... 1210 = 11002
68.310 + 12.210 = 1.100 0011 0011 ... x 23 0.210 Þ 0.2 x 2 0.4
0.4 x 2 0.8
0.8 x 2 1.6
0.6 x 2 1.2
0.2 x 2 0.4
...
only 24 bits can be stored
1 1 0 0 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
Change sign of Y
X = 1.01101 x 27
X+Y=Z 0.100101 x 27
Y = 0.110101 x 27
no no Expoenents yes Add signed Results yes
ADD X = 0? Y = 0? Round result
Equal? significands normalized?
yes yes no no
no 1.0001111 x 28
1.00101 x 26
RETURN Shift significand RETURN Significand no Decrement
right overflow? exponent
yes
Z= X × Y
Floating Point Arithmetic Operations –
Multiplication - Example
Floating Point Arithmetic Operations –
Division - Algorithm
Z= X / Y
Floating Point Arithmetic Operations –
Division - Example
Practice Questions
• Perform FP Addition, Subtraction, Multiplication and Division fore the
following inputs
• 123 and 25
• 154 and 10
Representation of Non Numeric Data
(Character Codes)
Non-Numeric Data Representation
There are several different variants of EBCDIC. Most of these differ in the punctuation coding.
EBCDIC character code in hexadecimal indices
EBCDIC control character representation
Practice Problems
• Represent the following numbers in a) Sign and Magnitude b) 1s
complement and c) 2’s complement representation
i) +24 ii) - 24 iii) -8 iv) +13 v) -37
• 2. Multiply the following numbers using Booth algorithm.
i) 11* 13
ii) 11* -13
iii) -11* - 13
• 3. Show the step by step multiplication process using AC , QR and Q-1
registers for the below number
i) -15* 5
Practice Problems
• 4. Multiply the following numbers using modified booth algorithm / Bit pair recoding( Try
one problem using the registers(A, Q , Q-1 ) method)
i) 23 * 10
ii) 14 * -2
iii) -12* 8
• 5. Divide the following numbers using restoring division algorithm
i) 14/7
ii) 28/11
• 6. Divide the following numbers using non- restoring division algorithm
i) 18/9
ii) 27/4
• 7. Represent the following number in IEEE- 754 format
i) 12312.13
ii) -14.5