Overflow in Arithmetic Addition in Binary Number System

Last Updated : 6 Apr, 2026

In binary arithmetic, an overflow happens when the result of an addition operation exceeds the capacity of the fixed bit allocation, resulting in an inaccurate value and possible sign errors in signed arithmetic.

  • Limited Memory: Computers have finite memory for storing numbers, restricting the size of values that can be represented.
  • Excess Bits: When the result of a computation requires more bits than available, the extra higher-order bits are discarded.
  • Erroneous Result: This loss of bits leads to an inaccurate outcome in the arithmetic operation.

Binary Number System

The binary number system is a base-2 numeral system that uses two symbols: 0 and 1. It forms the foundation of all digital systems and is widely used for data representation and processing in computers.

In this system, each binary digit (bit) represents an increasing power of 2 from right to left. Binary numbers are used in arithmetic operations, including addition using 2’s complement representation.

Conditions of Overflow

Overflow takes place when the result of the calculations exceeds the range of the number to be represented in a fixed number of bits with the help of 2’s complement format. Specifically, overflow happens under the following conditions:

1) Addition of Two Positives

When adding two positive numbers and the amount is more than the maximum amount that an N-bit system can hold, then over flow takes place. Incase it becomes the most significant bit is set to one signifying that the result is negative and this is wrong.

2) Addition of two negative number

When two negative numbers are added and the result is less than the minimum value that can be represented, overflow occurs. In this case, the MSB becomes 0, indicating a positive result, which is incorrect.

3) Variety of Carry in and Carry Out bits

This form of overflow is identified by comparing the carry-in and the carry-out relating to the MSB in an addition. However, if the two bits are at different state, that is C-in is not equal to C-out, then an overflow has taken place. This condition enables a determination of when the result cannot be represented using the available N–bit space.

N-bit 2's Complement representation for signed Integer can represent numbers from - 2^{n-1}     to 2^{n-1} -1     
4 Bit can represent numbers from ( -8 to 7 ) 
5 Bit can represent numbers from ( -16 to 15 ) in 2's Complimentary System. 

2's complement

Adding 7 + 1 in 4-Bit must be equal to 8. But 8 cannot be represented with 4 bit 2's complement number as it is out of range. Two Positive numbers were added and the answer we got is negative (-8). It is normally left to the programmer to detect overflow and deal with this situation. 

Overflow Detection

Overflow occurs when:  

  1. Two negative numbers are added and an answer comes positive or 
  2. Two positive numbers are added and an answer comes as negative. 

Let us understand more in-depth. Consider the below scenarios,

  1. If x & y are +ve numbers then x+y > max(x,y)
  2. if x & y are -ve numbers then x+y < min(x,y)
  3. If x is +ve and y is -ve then y< x+y < x

Considering the above scenarios we can also say that - If we add two operands of same sign and get result of opposite sign, overflow occurs.

Overflow can be detected by checking the most significant bit (MSB) of the two operands and the result. If two operands have the same sign and the result has a different sign, overflow has occurred.

Alternatively, overflow can be detected without comparing three bits by using the carry-in (C-in) and carry-out (C-out) of the MSB. If C-in is not equal to C-out, then overflow has occurred.

Consider the N-bit addition of 2’s complement numbers.

MSB

Overflow Occurs when C-in \neq     C-out. The above expression for overflow can be explained below Analysis.  

Overflow Analysis

  • In first Figure the MSB of two numbers are 0 which means they are positive. Here if C-in is 1 we get answer's MSB as 1 means answer is negative (Overflow) and C-out as 0. C-in \neq     C-out hence overflow. 
  • In second Figure the MSB of two numbers are 1 which means they are negative. Here if C-in is 0 we get answer MSB as 0 means answer is positive(Overflow) and C-out as 1. C-in \neq     C-out hence overflow. 

Hence, from above discussion we can also conclude that - If carry for MSB(c-in) and carry from MSB(c-out) is different ( considering first figure 1 and 0 respectively) then overflow occurs. Else there is no overflow.

Readers can also try out other combinations of c-in(carry for MSB) c-out(carry from MSB) and MSB's to check overflow.  So Carry-in and Carry-out at MSB's are enough to detect Overflow. 

XOR GATE

The above XOR Gate can be used to detect overflow.

Comment

Explore