Evaluate 2’s complement of 9 bits including sign bit. ii) Subtract 224 from –99 – IGNOU MCA Assignment 2014 -15

By | September 23, 2014

MASTER OF COMPUTER APPLICATIONS
Course Code : MCS-012
Course Title : Computer Organisation and Assembly Language Programming
Assignment Number : MCA (2)/012/Assign /2014-15
Maximum Marks : 100
Weightage : 25%

Perform the following arithmetic operations:-

Using binary signed 2’s complement notation for integers. You may assume that the maximum size of integers is of 9 bits including the sign bit. (Please note that the numbers given here are in decimal notation).

i)                    Add – 256 and 206

ii)                  Subtract 224 from –99

Please indicate the overflow if it occurs. Also write how you identify overflow.

ii) Subtract 224 from –99

First, we have to represent the number in binary notation

The sign of a binary number is represented by 0 as plus and 1 as minus

Sign bit                                 8 -bits

 0 / 1

Now, Binary value of the given number

99 – 01100011

224 – 11100000

-99 :-

Sign bit                                 8 -bits

 1 0 1 1 0 0 0 1 1

+224 :-

Sign bit                                 8 -bits

 0 1 1 1 0 0 0 0 0

In Binary, Subtraction is not done directly it is done by taking a MINUS sign for a positive number.

For subtraction changing +224 to -224:-

-224 :-

Sign bit                                 8 -bits

 1 1 1 1 0 0 0 0 0

Now, covert it to signed 2’s complement notation:-

-99 :-

Sign bit                                 8 -bits

 1 1 0 0 1 1 1 0 1

-224 :-

Sign bit                                 8 -bits

 1 0 0 1 0 0 0 0 0

Simple trick to convert any binary value to its signed 2’s complement notation is Check for the first one (i.e. 1) in the magnitude of the number from Right to Left when you find it, Keep the number unchanged till one (i.e. 1) and remaining number reverse it by changing value from 0 to 1 and vice-verse.

-99 :-

Sign bit                                 8 -bits

 1 1 0 0 1 1 1 0 1

-224 :-

 1 0 0 1 0 0 0 0 0

-323 :-

Carry bit

 1 0 1 0 1 1 1 1 0 1

Overflow condition occured.

The magnitude has been overflowed into carry the given 8-bits are not sufficient for the result of the magnitude.