# How to find out if the input of a logic gate is negative in two's complement?

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.

• "not in two's complement" two's complement is a definition, not a state. As such you can not detect if a signal is two's complement or not. (Assuming only ones and zeros). Nov 2, 2018 at 14:49
• It's not clear what you're asking, since two's complement would be a number, or a collection of bits. And the most significant bit is the sign, meaning you already have the answer, without doing anything. Nov 2, 2018 at 14:51
• @Oldfart I think it's meant to be parsed as (whether the input is a negative number or not) (in two's complement). Nov 2, 2018 at 15:30

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.