◄ WORLD V · SONNY 5DART 382 · a helldive at the net

THE OVERFLOW (V) FLAG the carry that lied about the sign — signed overflow is a carry mismatch

For signed numbers the carry flag is the wrong alarm. In two's complement the top bit is the sign, and the real danger is a result too big to be signed: 127+1 in a byte gives −128 — two positives summing to a negative. The overflow flag (V) catches exactly that, and its definition is pure carry: V is set when the carry into the sign bit differs from the carry out of it. Same adder, same carries — a different bit read from them. The carry flag is unsigned overflow; the overflow flag is signed overflow; both are the carry, interpreted.

THE TECHNIQUE V = (carry into sign bit) ⊕ (carry out of sign bit)

The demo adds 127+1 signed — the result flips to −128 and V is set: two positives made a negative: live demo


HISTORY & CREDIT the signed-overflow (V) flag

“Overflow is one condition.” — unsigned overflow (C) and signed overflow (V) are different bits from the same carries; using C on signed data is a classic bug. cited

V · carry-in to the sign bit XOR carry-out of it — the two disagree exactly when the sign is wrong.
tell · two positives → negative, or two negatives → positive.
vs C · C is unsigned overflow, V is signed; same adder, different flag.

When the carry into the sign and the carry out of it disagree, the sign is a lie — and V says so. The carry, read for sign. the V flag

RECOMMEND FOR I-13 the signed overflow, on the compiler

On the canonical compiler, 127+1 gives raw 128 = signed −128 — overflow (V=1), two positives making a negative:

$ i13 run c_overflowflag.i13 # 127 + 1 signed RUN OK · 18 step(s) · peak stack 2 · call depth 0 raw = 128 wrap = -128 -- 127 + 1 flips the sign V = 1 -- signed overflow: two positives -> negative
Recommend: the overflow flag is the carry read for sign — V is set when the carry into the sign bit and out of it disagree — and i13 flags 127+1→−128. Not a keeper (a signed-overflow detector is a recognizer, per B41 — it reports a property of the result). The dart that shows one adder's carries yield two different overflow bits, and using the wrong one is a bug that ships.