What is overflow and underflow which occur in a digital comp
What is overflow and underflow which occur in a digital computer?
Solution
Overflow is the concept which occurs when you\'re adding 2 numbers. When adding 2 numbers of n-bit, if the result doesn\'t fit in n-bit which usually requires an additional bit, an overflow will occur which means an overflow flag is set. For example assume the addition 15 + 4 and we\'re performing 4-bit operation. 15 can be represented using 4 bits as 1111, and 4 can also be represented using 4 bits as 0100. And the summation will result in a value 19 which requires a total of 5 bits to represent. So, here we can say that an overflow occurred.
On the other hand underflow occurs when you\'re trying to represent a floating post values. For example there is a limit in the number of bits of precision that can be achieved on a digital computer. For example using 4 bits we can represent a precision of only up to .0001. But if you tried to go beyond this, an underflow occurs.
The other place where you also use the terminology of overflow and underflow in digital computers is when you\'re dealing with stacks. When you try to push an element to a stack beyond its capacity, a stack overflow will occur, and when you try to pop an element from an empty stack, a stack underflow occurs. This is called stack overflow and underflow. And the previous one is called arithmetic overflow and underflow.
