vlsibank

Log in or Sign up.
Main EDA Embedded Systems ASIC FPGA VHDL Verilog CMOS Semiconductors DSP Mixed Signal Architecture Miscellaneous

<-- Previous Next -- > TOPIC: Query: Twos complement representation
Posted by: nithinthemax     8/17/2005 1:34:16 AM     Category: Semiconductors
Questions posted: 2         Comments Posted: 1
Can anyone tell what is the difference between twos complement representation of a postitve and a negative number (eg: +8 & -8)...  It was asked in an interview...
Actually two's complement is used to represnt negative nos:,, but.....
     Pls if anyone of you who reads knows abt it pls reply..
     Thanking you in advance

Posted by: palam8282     9/7/2005 1:11:27 PM
Comments Posted:4       

Hi

assume 8-bit representation of number.

Two's complement of positive numbers starts with '0'(MSB)
Two's complement of negative numbers starts with '1' (MSB)

+8/ 0000 1000
-8/ 1111 1000

So in 2's comp, when ever it starts with MSB=1, it represents a negative number.

Hope it will help you.

thanks


Posted by: fresher@vlsi     8/19/2005 12:32:38 AM
Comments Posted:7       Questions Posted:1

To find twos complement there are two  ways

1.Find 1s complement and add 1.
2.as khushin has described above.

THNX


Posted by: nithinthemax     8/18/2005 3:44:16 AM
Comments Posted:1       Questions Posted:2

MY question is how to find twos complement of  +8 and -8?  IS there any difference??
      Anyway thanks for ur reply


Posted by: fresher@vlsi     8/17/2005 5:11:36 AM
Comments Posted:7       Questions Posted:1

Two's complement representation of numbers is different from normal representation ie using four bits one can represent from 0 to 15 in normal binary,but in two's complement it can represent
only from -7 to +7(three bits) and +8(four bits) {16 numbers in total}.It is similar to sign extended representation of numbers.with 0 in the MSB representing positive numbers and
1 for negative numbers.So +8 and -8 differs only in
MSB.Please correct me incase i am wrong


Posted by: khushin     8/17/2005 3:21:42 AM
Comments Posted:8       Questions Posted:6

hi
Consider the 2s complement representation:   11100
We start copying from right to left, and the first digit we copy is a 1  so this gives us:
                                   100
We complement the remaining digits, which gives us:
                                  00100
We then convert this from binary to decimal, giving us the result of 4
Our original bit pattern in step 1 started with a sign bit of 1, so that means that our original bit pattern represents a negative value in 2's complement, so our final result is: -4.


suppose u want do perform  0-7=-7
using 2's complement

first   0111 now take 2's com..  1001

0000+1001=1001
so now u convert it to decimal it is not 9 but -7 i think this will help u
thanks




You have to be logged in to be able to post a comment. To login click here. First time? Sign up. It just takes a few minutes to sign up.

Login to access the site

  Username:
  Password:
   Signup Forgot Password?    

Users with most replies

   User
 No. of Replies
264
104
86
76
75
70
63
61
57