in Digital Logic retagged by
467 views
0 votes
0 votes
Hi,

Can someone please tell if gray code representation can also work for negative binary number?

I’ve seen examples of gray code for only positive binary number not sure about negative , can someone pls clear the doubt ?
in Digital Logic retagged by
by
467 views

1 comment

Since, you have not mentioned the meaning of “negative binary numbers”, so I am considering $2’s$ complement to represent signed numbers or more specifically signed integers.

Suppose, you have to find gray code for $-2.$

Now, there can be many binary 2’s complement representation for $-2,$ for example,

  1. $110 = -2^2*1 + 2^1*1 + 2^0*0 = -4 +2 + 0 = -2$
  2. $1110 = -2^3*1 + 2^2*1 + 2^1*1 + 2^0*0 = -8 + 4 +2 + 0 = -2$  
  3. $11110 = -2^4*1 + 2^3*1+2^2*1 + 2^1*1 + 2^0*0 = -16 +8 + 4 +2 + 0 = -2$

and so on.

Now, the corresponding gray-code will be 

  1. $101$ for $110$
  2. $1001$ for $1110$
  3. $10001$ for $11110$

and so on.

So, there is no unique gray code for a single negative number. This is the problem with negative numbers but you will not find this problem with non-negative integers.

0
0

Please log in or register to answer this question.

Related questions