Integer Overflow
Last updated
Last updated
Definition : Overflow the limitation of a program with an integer.
In any language, not only C, have its own and . It has it's own limitation value. However, in can be limited by the program itself.
-32,768 bits
short
32,767 bits
-2,147,483,648
int
2,147,483,647
-9,223,372,036,854,775,808 bits
long
9,223,372,036,854,775,807 bits
0
unsigned short int
65,535
0
unsigned int
4,294,967,295
-128
signed char
127
0
unsigned char
255
Knowing the limitation of the variable type is a must
Try to input something so that the variable will exceed the limit
--
For a better understanding on how it works, look at your analog clock. The clock has a limit of 12 numbers only. Let say the time right now is 9 am. In 12 hours, the clocks points back at number 9 but in pm. It does not point at number 21 right? Yeah that's how i understanding the limitations (i know it does not make sense, but why not )