Electrical – How to find out if the input of a logic gate is negative in two’s complement

alubinarydigital-logiclogic-gates

I'm trying to create something which will output whether the input of the logic gate is a negative number or not in two's complement. I understand how twos complement works etc, but i'm not entirely sure how I would convert that into logic gates. I was perhaps thinking of using a Not gate at the start since there would only be one input and one output as well.

Thanks.

Best Answer

In two’s complement, the most significant bit (MSB) of all \$ N \$ bits involved is the sign indicator, so it would be sufficient to just look at the MSB of the bits going into your logic gate. Is it 0, then the number is positive. Is it 1, then the number is negative and you have to subtract \$ 2^{(N-1)} \$ from the number represented by the other \$ N-1 \$ bits in order to get the value.

A NOT gate's output of which the input is fed with the MSB will reflect the state of the input number. 0 means positive, 1 means negative.