Skip to content
BetterDL

Negative flag (N)

Also called: N flag, sign flag

The status flag N, a copy of the result's most significant bit. N = 1 means the result is negative when read as a two's complement number.

The negative flag N is the simplest status flag: it's a copy of the MSB of the ALU's result. For an n-bit result R, N = Rₙ₋₁. No gates needed, just a wire.

N = 1 means the result is negative if you read it as twos complement. For unsigned results N says nothing about sign; it's just the top bit.

Three things to keep straight:

  • N isn't an error. Negative results are normal. Overflow is a separate question, answered by the overflow flag V.
  • N can be wrong after overflow. If a signed operation overflowed, the result's sign is flipped, so N misreports the true answer. That's why signed less-than uses rather than N alone (see comparison by subtraction).
  • N comes from the ALU output, after the result multiplexer, so it's right for every operation, logic ones included. Taking it from the adder's sum would be wrong whenever the ALU outputs an AND or OR result.

x86 processors call it the sign flag. It's the sign bit of the result, captured.

1
−8
1
4
1
2
0
1

Worked example

Example

N with and without overflow

Two 4-bit additions.

  1. 1.

    0011 + 0010 = 0101. N = 0 and V = 0: positive, and correct.

  2. 2.

    0110 + 0011 = 1001. N = 1, but the carries are C3 = 1, C4 = 0, so V = 1.

  3. 3.

    The true sum, 6 + 3 = 9, is positive. N is wrong because of the overflow, and N ⊕ V = 0 gives the right sign.

Common mistakes

  • Treating N = 1 as an error.

  • Trusting N alone for signed comparisons. Use N ⊕ V.

  • Taking N from the adder instead of the ALU output.

Practice Negative flag (N)

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

Negative flag (N) is taught in Adders and ALUs and Basic CPU / Computer Architecture.