0% found this document useful (0 votes)
29 views23 pages

Data Stucture Unit - 3 - Computer Arithmetic - B.C.A Study

The document discusses computer arithmetic and binary number systems. It explains that binary uses only two symbols, 0 and 1, in a base-2 positional notation. Various integer values from 0 to 15 are shown converted to their binary representations. The document also covers basic concepts of decimal and binary number systems. It defines how to determine the decimal equivalent of a binary number by summing the product of each bit and its corresponding power of two. Additional topics covered include binary multiplication and division algorithms, floating point number representation, and converting between decimal and floating point formats.

Uploaded by

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

Data Stucture Unit - 3 - Computer Arithmetic - B.C.A Study

The document discusses computer arithmetic and binary number systems. It explains that binary uses only two symbols, 0 and 1, in a base-2 positional notation. Various integer values from 0 to 15 are shown converted to their binary representations. The document also covers basic concepts of decimal and binary number systems. It defines how to determine the decimal equivalent of a binary number by summing the product of each bit and its corresponding power of two. Additional topics covered include binary multiplication and division algorithms, floating point number representation, and converting between decimal and floating point formats.

Uploaded by

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

9/10/23, 10:29 AM 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/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

Decimal basic concepts:

Decimal is base 10.

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

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 :

100110112 = (20*1) + (21*1) + (23*1) + (24*1) + (27*1) =155

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

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.

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.

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/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

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 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

You might also like