0% found this document useful (0 votes)
44 views

Chapter 1 - Hardware: Overflow

This document discusses overflow and underflow in computing. It defines overflow and underflow as situations where a value becomes too large or small to be stored correctly. It then covers the rules for detecting overflow in two's complement addition, including that adding a negative and positive number cannot overflow. The document also discusses overflow conditions for unsigned, signed-magnitude, and two's complement numbers. It provides an example of converting an 8-bit two's complement number to decimal.

Uploaded by

May Thin Khine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Chapter 1 - Hardware: Overflow

This document discusses overflow and underflow in computing. It defines overflow and underflow as situations where a value becomes too large or small to be stored correctly. It then covers the rules for detecting overflow in two's complement addition, including that adding a negative and positive number cannot overflow. The document also discusses overflow conditions for unsigned, signed-magnitude, and two's complement numbers. It provides an example of converting an 8-bit two's complement number to decimal.

Uploaded by

May Thin Khine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Chapter 1 - Hardware

Overflow

Khin Wai Wai Kyaw


IT Lecturer
Overflow and Underflow
• Overflow and underflow describe the situation when something becomes too big
or too small to be processed correctly or stored in the space allocated to it
correctly.
Two’s Complement Overflow Rules
The rules for detecting overflow in a two's complement sum are:
• If the sum of two positive numbers yields a negative result, the sum has
overflowed.
• If the sum of two negative numbers yields a positive result, the sum has
overflowed. Otherwise, the sum has not overflowed.
• A negative and positive added together cannot overflow, because the sum is
between the addends.
• In unsigned numbers, carry out is equivalent to overflow. In two's complement,
carry out tells you nothing about overflow.
Overflow condition in unsigned number

• If calculation result exceeds the range 0 to 2n -1 an overflow occurs.


• Let us consider the addition of two unsigned 4-bit numbers.

 
Overflow condition in signed-magnitude number

• If calculation result exceeds the range -2n-1 – 1 to +2n-1 -1 and the signed bit of answer to
change occurring an overflow.
• Let us consider the addition of two signed-magnitude 4-bit numbers.
Overflow condition in 2’s Complement
number
When 4-bit signed numbers in 2's complement are used, which of the following operations
will cause either an overflow or an underflow?
a) Add B to A when A is 0110 and B is 1111.
b) Add B to A when A is 1110 and B is 0110.
c) Subtract B from A when A is 0111 and B is 1010.
d) Subtract B from A when A is 1111 and B is 1111.
Two’s Complement to Decimal Conversion
• Converting an eight-bit two's complement number to decimal.
• If the number is negative or positive by looking at the sign bit.
• If it is positive, simply convert it to decimal. If it is negative, make it positive by
inverting the bits and adding one. Then, convert the result to decimal. The
negative of this number is the value of the original binary.

You might also like