

If the value is more than the maximum representable value, the phenomenon is called Integer Overlow. When we attempt to store a value that cannot be represented correctly by a data type, an Integer Overflow (or) Underflow occurs. By definition, the sum would not fit in the int data type, resulting in Overflow.

In the above example, we're trying to add 1 to INT_MAX. Such limits are defined in the header limits.h. Since a fixed amount of bits are allocated to store integers, naturally, a finite limit exists to represent an integer correctly. There are also smaller datatypes like short int that occupy 16 bits. All the modern computers support 32-bit and 64-bit sized integers. Like any other variable, Integers are just some bytes of memory. We discuss methods to prevent it both mathematically and programmatically. We describe the Integer Overflow and Underflow in C, causes, and their prevention. We will see several methods to detect these errors in this article. It makes overflow errors very subtle and dangerous. Integer Overflow and Integer Underflow in C, do not raise any errors, but the program continues to execute (with the incorrect values) as if nothing has happened. Integer Overflow is a phenomenon that occurs when the integer data type cannot hold the actual value of a variable.
