The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+22 votes
2.9k views

$P$ is a $16$-bit signed integer. The $2$'s complement representation of $P$ is $(F87B)_{16}$. The $2$'s complement representation of $8\times P$ is

  1. $(C3D8)_{16}$
  2. $(187B)_{16}$
  3. $(F878)_{16}$
  4. $(987B)_{16}$
asked in Digital Logic by Veteran (103k points)
edited by | 2.9k views
0

$Remark:$

One arithmetic shift to left multiplies the number by 2, but we lose left most bits one by one

                        (AshiftL#2, R0)

Answer is (A).

PS: Arithmetic shift to left is same as Logical shift to left.

1 Answer

+34 votes
Best answer
Multiplication can be directly carried in 2's complement form. F87B = 1111 1000 0111 1011 can be left shifted 3 times to give 8P = 1100 0011 1101 1000 = C3D8.

Or, we can do as follows:

MSB in (F87B) is 1. So, P is a negative number. So, P = -1 * 2's complement of (F87B) = -1 * (0785) = -1 * (0000 0111 1000 0101)

8 * P = -1 *  (0011 1100 0010 1000) (P in binary left shifted 3 times)

In 2's complement representation , this equals, 1100 0011 1101 1000 = C3D8
answered by Veteran (358k points)
selected
+5
The first one was quite easier. :)
0
why binary left shift why not right shift ?
+9
Left shift means adding a 0 at right end, which is equivalent to multiply by 2 in binary. Right shift will be doing division by 2.
+1
ya rgt thanks:)
+1
suppose iif the question asks 10*P then ??
+9
@Puja you can do it  (10*P = 8*P + 2*P) where (8*P) you shift 3 digit left and then for (2*P) you can shift it 1 digit left and then add it.
+1
sir I want to know why should be shift 3 times ?

if it is 9 then ?
+1
@hem chandra

Left shift  is equal to multiplication and right shift equals to division in binary numbers, for the factor of 2 like 2 , 2^2, 2^3 .............

Since here it is 8 , it is 2^3. So we need to shift 3 times
+2
if there is 9p then 8p+1p = 2^3p+2^0p (overall three left shifts)
+1
Thank You so much for this explanation :)
+1

Puja Mishra 

If you do 10*P then You will get

= 8*P + 2*P

= 1 1011 0100 1100 1110

This is the Case of Overflow as said in Question P is 16 Bit Signed Integer.

So i guess there will be one option of overflow in this scenario.

0
@krishn.jh It won't be overflow because for overflow $C_{in} \neq C_{out}$ but here $C_{in} = C_{out} = 1$
0
@Akhilesh so you mean to say

if you do 8*P + 2*P then no overflow will occur?
0
It will be end carry, which is discarded in 2's complement.

And in 2's complement we can forget all 1s in MSBs, except one 1.
Eg. 111011 = 1011

Thus, we can forget the end carry in our result of 8P+2P because sign(negative here) as well as value is still preserved.
0
@Akhilesh ok yes i know as concept says preceding 1's does not affect the values in 2's Complement as they make one partial block.

i got it as after discarding the carry 1, it is not going to affect the final result.

But Be careful  as if sum is 0 carry 1 in MSB place then surely there would be Overflow.
0
1010=10

then after left shift by 1 bit it becomes 0100=4 ,why didnt i get 20?


Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

40,844 questions
47,506 answers
145,764 comments
62,261 users