16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.
A study
B.C.A study
Unit -3 : Computer Arithmetic
Binary numeral system (base2 number system) is
numeric values using 2 symbols: 0 &1
a positional notation with a radix of 2
Example of binary number and integers:
Integer
Binary Number
02
12
102
https://bcastudyguide.com/unit-3-computer-arithmetic/ 1/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
112
1002
1012
1102
1112
10002
10012
10
https://bcastudyguide.com/unit-3-computer-arithmetic/ 2/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
10102
11
10112
12
11002
13
11012
14
11102
15
11112
16
100002
Decimal basic concepts:
Decimal is base 10.
https://bcastudyguide.com/unit-3-computer-arithmetic/ 3/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
There are 10 digits in counting (0, 1, 2, 3, 4, 5, 6, 7, 8, 9).
When you reach 10, you carry “1” over to the next column (left side).
The number after 9 is 10.
Binary basic concept:
Decimal base is 2.
There are 2 digits in counting (0, 1).
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
0100, 0101, 0111
1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111
0 1
In binary system, each digit represents an increase of power of 2, therefore rightmost digit is 2 , follow by 2 ,
2 3
2 , 2 ….To determine the decimal representation of binary number, we sum up product at binary digit and
power 2 which they represent.
Example 1 :
100110112 = (20*1) + (21*1) + (23*1) + (24*1) + (27*1) =155
https://bcastudyguide.com/unit-3-computer-arithmetic/ 4/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 5/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 6/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 7/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 8/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 9/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 10/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 11/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 12/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 13/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 14/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 15/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 16/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 17/22
16/08/2024, 15:57 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/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
Restoring Division Algorithm For Unsigned Integer
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.
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.
https://bcastudyguide.com/unit-3-computer-arithmetic/ 19/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
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.
Let’s pick the step involved:
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/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
https://bcastudyguide.com/unit-3-computer-arithmetic/ 21/22
16/08/2024, 15:57 Unit -3 : Computer Arithmetic – B.C.A study
Introduction of Floating Point Representation
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
k-1
point representation. It is known as bias. It is determined by 2 -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.
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 . Hence the
4
exponent of 2 will be 4 since 2 = 16. 127 is the unique number for 32 bit floating point representation. It is
k-1
known as bias. It is determined by 2 -1 where ‘k’ is the number of bits in exponent field.Thus bias = 127
8-1
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
4
exponent of 2 so that the value does not change. This is normalizing the number. 1.0001 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/ 22/22