0
votes

I have some real data. For example +2 and -3. These data are represented in two's complement fixed point with 4 bit binary value where MSB represents the sign bit and number of fractional bit is zero.

So +2 = 0010

-3 = 1101

addition of this two numbers is (+2) + (-3)=-1

(0010)+(1101)=(1111)

But in case of subtraction (+2)-(-3) what should i do?

Is it needed to take the two's complement of 1101 (-3) again and add with 0010?

1
What is tows? And these are pure integers, not fixed-point valuesphuclv
sorry for the error. It should be two's complement. I know these are pure integers but above example can be extended for fractional value also.Sourav

1 Answers

0
votes

You can evaluate -(-3) in binary and than simply sums it with the other values.

With two's complement, evaluate the opposite of a number is pretty simple: just apply the NOT binary operation to every digits except for the less significant bit. The equation below uses the tilde to rapresent the NOT operation of a single bit and assumed to deal with integer rapresented by n bits (n = 4 in your example):

enter image description here

In your example (with an informal notation): -(-3) = -(1101) = 0011