encyclopegia.org

Overflow flag

In computer processors, the overflow flag (sometimes called the V flag) is usually a single bit in a system status register used to indicate when an arithmetic overflow has occurred in an operation, indicating that the signed two's-complement result would not fit in the number of bits used for the result.[src] Some architectures may be configured to automatically generate an exception on an operation resulting in overflow.[src] An example, suppose we add 127 and 127 using 8-bit registers.[src] 127+127 is 254, but using 8-bit arithmetic the result would be 1111 1110 binary, which is the two's complement encoding of −2, a negative number.[src] A negative sum of positive operands (or vice versa) is an overflow.[src] The overflow flag would then be set so the program can be aware of the problem and mitigate this or signal an error.[src] The overflow flag is thus set when the most significant bit (here considered the sign bit) is changed by adding two numbers with the same sign (or subtracting two numbers with opposite signs).[src] Overflow cannot occur when the sign of two addition operands are different (or the sign of two subtraction operands are the same).[src] When binary values are interpreted as unsigned numbers, the overflow flag is meaningless and normally ignored.…[src]

In computer processors, the overflow flag (sometimes called the V flag) is usually a single bit in a system status register used to indicate when an arithmetic overflow has occurred in an operation, indicating that the signed two's-complement result would not fit in the number of bits used for the result.[src] Some architectures may be configured to automatically generate an exception on an operation resulting in overflow.[src] An example, suppose we add 127 and 127 using 8-bit registers.[src] 127+127 is 254, but using 8-bit arithmetic the result would be 1111 1110 binary, which is the two's complement encoding of −2, a negative number.[src] A negative sum of positive operands (or vice versa) is an overflow.[src] The overflow flag would then be set so the program can be aware of the problem and mitigate this or signal an error.[src] The overflow flag is thus set when the most significant bit (here considered the sign bit) is changed by adding two numbers with the same sign (or subtracting two numbers with opposite signs).[src] Overflow cannot occur when the sign of two addition operands are different (or the sign of two subtraction operands are the same).[src] When binary values are interpreted as unsigned numbers, the overflow flag is meaningless and normally ignored.[src] One of the advantages of two's complement arithmetic is that the addition and subtraction operations do not need to distinguish between signed and unsigned operands.[src] For this reason, most computer instruction sets do not distinguish between signed and unsigned operands, generating both (signed) overflow and (unsigned) carry flags on every operation, and leaving it to following instructions to pay attention to whichever one is of interest.[src] Internally, the overflow flag is usually generated by an exclusive or of the internal carry into and out of the sign bit.[src] Bitwise operations (and, or, xor, not, rotate) do not have a notion of signed overflow, so the defined value varies on different processor architectures.[src] Some processors clear the bit unconditionally (which is useful because bitwise operations set the sign flag, and the clear overflow flag then indicates that the sign flag is valid), others leave it unchanged, and some set it to an undefined value.[src] Shifts and multiplies do permit a well-defined value, but it is not consistently implemented.[src] For example, the x86 instruction set only defines the overflow flag for multiplies and 1-bit shifts; multi-bit shifts leave it undefined.[src] ==References==[src]

26 sentences · 26 cited inline · 0 references stored

References

No reference rows published for this article.

Cite this article

MLA

"Overflow flag." encyclopegia.org, 2022, https://encyclopegia.org/wiki/overflow-flag. Accessed 26 November 2026.

Chicago

"Overflow flag." encyclopegia.org. Accessed November 26, 2026. https://encyclopegia.org/wiki/overflow-flag.

APA

encyclopegia.org. (2022). Overflow flag. Retrieved November 26, 2026, from https://encyclopegia.org/wiki/overflow-flag

Accessed November 26, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

flag of the Faroe Islands

stub · references available

flag

stub · references available

flag of Staffordshire

stub · references available

flag of South Carolina

stub · references available

flag of North Carolina

stub · references available

flag of Oregon

stub · references available

flag of Japan

stub · references available

flag of Jerusalem

stub · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1116985111 · 0.5 · snapshot enwiki-001116985111

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.