Data Stucture Unit - 3 - Computer Arithmetic - B.C.A Study
Data Stucture Unit - 3 - Computer Arithmetic - B.C.A Study
A study
B.C.A study
Integer
Binary Number
02
12
102
https://bcastudyguide.com/unit-3-computer-arithmetic/ 1/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
112
1002
1012
1102
1112
10002
https://bcastudyguide.com/unit-3-computer-arithmetic/ 2/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
10012
10
10102
11
10112
12
11002
13
11012
14
11102
15
11112
https://bcastudyguide.com/unit-3-computer-arithmetic/ 3/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
16
100002
When you reach 10, you carry “1” over to the next column (left side).
Decimal base is 2.
When you reach 2, you carry “1” over to the next column (left side).
We beginning with single digit, counting proceeds through each symbol in ascending order using
only 0 &1. When the first digit is exhausted, next higher digit (to left) is incremented and counting
start over at 0.
0000
0001
0010, 0011
In binary system, each digit represents an increase of power of 2, therefore rightmost digit is 20,
follow by 21, 22, 23….To determine the decimal representation of binary number, we sum up product
at binary digit and power 2 which they represent.
Example 1 :
https://bcastudyguide.com/unit-3-computer-arithmetic/ 4/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 5/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 6/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 7/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 8/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 9/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 10/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 11/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 12/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 13/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 14/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 15/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 16/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 17/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
Multiplication algorithm –Booth’s algorithm is a multiplication algorithm that multiplies two signed
binary numbers in 2’s compliment notation.
https://bcastudyguide.com/unit-3-computer-arithmetic/ 18/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
A division algorithm provides a quotient and a remainder when we divide two number. They are
generally of two type slow algorithm and fast algorithm. Slow division algorithm are restoring, non-
restoring, non-performing restoring, SRT algorithm and under fast comes Newton–Raphson and
Goldschmidt.
https://bcastudyguide.com/unit-3-computer-arithmetic/ 19/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
In this article, will be performing restoring algorithm for unsigned integer. Restoring term is due to
fact that value of register A is restored after each iteration.
Here, register Q contain quotient and register A contain remainder. Here, n-bit dividend is loaded in
Q and divisor is loaded in M. Value of Register is initially kept 0 and this is the register whose value
is restored during iteration due to which it is named Restoring.
Step-1: First the registers are initialized with corresponding values (Q = Dividend, M = Divisor, A
= 0, n = number of bits in dividend)
Step-2: Then the content of register A and Q is shifted left as if they are a single unit
Step-3: Then content of register M is subtracted from A and result is stored in A
Step-4: Then the most significant bit of the A is checked if it is 0 the least significant bit of Q is set
to 1 otherwise if it is 1 the least significant bit of Q is set to 0 and value of register A is restored i.e
the value of A before the subtraction with M
Step-5: The value of counter n is decremented
Step-6: If the value of n becomes zero we get of the loop otherwise we repeat from step 2
Step-7: Finally, the register Q contain the quotient and A contain remainder
Examples:
https://bcastudyguide.com/unit-3-computer-arithmetic/ 20/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 21/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
1. To convert the floating point into decimal, we have 3 elements in a 32-bit floating point
representation:
i) Sign
ii) Exponent
iii) Mantissa
Sign bit is the first bit of the binary representation. ‘1’ implies negative number and ‘0’ implies
positive number.
Example: 11000001110100000000000000000000 This is negative number.
Exponent is decided by the next 8 bits of binary representation. 127 is the unique number for 32
bit floating point representation. It is known as bias. It is determined by 2k-1 -1 where ‘k’ is the
number of bits in exponent field.There are 3 exponent bits in 8-bit representation and 8 exponent
bits in 32-bit representation.
Thus
3-1
bias = 3 for 8 bit conversion (2 -1 = 4-1 = 3)
8-1
bias = 127 for 32 bit conversion. (2 -1 = 128-1 = 127)
Example: 01000001110100000000000000000000
10000011 = (131)10
4
131-127 = 4Hence the exponent of 2 will be 4 i.e. 2 = 16.
Mantissa is calculated from the remaining 23 bits of the binary representation. It consists of ‘1’
and a fractional part which is determined by:
Example:01000001110100000000000000000000
The fractional part of mantissa is given by:1*(1/2) + 0*(1/4) + 1*(1/8) + 0*(1/16) +……… = 0.625Thus
the mantissa will be 1 + 0.625 = 1.625The decimal number hence given as: Sign*Exponent*Mantissa
= (-1)*(16)*(1.625) = -26
2. To convert the decimal into floating point, we have 3 elements in a 32-bit floating point
representation:
i) Sign (MSB)
ii) Exponent (8 bits after MSB)
iii) Mantissa (Remaining 23 bits)
Sign bit is the first bit of the binary representation. ‘1’ implies negative number and ‘0’ implies
positive number.
https://bcastudyguide.com/unit-3-computer-arithmetic/ 22/23
9/10/23, 10:29 AM Unit -3 : Computer Arithmetic – B.C.A study
Example: To convert -17 into 32-bit floating point representation Sign bit = 1
n n
Exponent is decided by the nearest smaller or equal to 2 number. For 17, 16 is the nearest 2 .
4
Hence the exponent of 2 will be 4 since 2 = 16. 127 is the unique number for 32 bit floating point
representation. It is known as bias. It is determined by 2k-1 -1 where ‘k’ is the number of bits in
8-1
exponent field.Thus bias = 127 for 32 bit. (2 -1 = 128-1 = 127)Now, 127 + 4 = 131 i.e. 10000011 in
binary representation.
Mantissa: 17 in binary = 10001.Move the binary point so that there is only one bit from the left.
Adjust the exponent of 2 so that the value does not change. This is normalizing the number. 1.0001
4
x 2 . Now, consider the fractional part and represented as 23 bits by adding
zeros.00010000000000000000000
A WordPress.com Website.
https://bcastudyguide.com/unit-3-computer-arithmetic/ 23/23