Integer overflow
in programming, a condition that occurs when an arithmetic operation attempts to create a numeric value that is outside of the range that can be represented with a given number of digits
Integer overflow occurs in computers, when the number which is stored becomes larger than the capacity of the memory it is stored in. The most likely result is that the number will reset to 0 and start over.
![](http://upload.wikimedia.org/wikipedia/commons/thumb/5/53/Odometer_rollover.jpg/250px-Odometer_rollover.jpg)
For example, start with the number 14, using 4-bits integers. Add 1 a few times, this will result in an overflow, which causes it to reset the number to 0.
Binary number | Decimal number |
---|---|
1110 | 14 |
1111 | 15 |
0000 | 0 |
0001 | 1 |
Another result is the number will reset to the most negative number, if the number has a sign. This is because negative numbers are represented by values after the maximum positive value.
For example, with signed 4-bit integers. Adding 1 will cause this type of overflow:[1]
Binary number | Decimal number |
---|---|
0110 | 6 |
0111 | 7 |
1000 | -8 |
1001 | -7 |
References
🔥 Top keywords: Main PageSpecial:SearchSupreme Court of the United StatesList of UEFA European Championship finalsWikipedia:AboutList of U.S. statesHelp:ContentsHelp:IntroductionKnights of the Round TableList of Disney moviesBlackSpecial:RecentChangesGodzilla X Kong: The New EmpireList of people who have walked on the MoonList of U.S. states and territories by time zoneUnited StatesThe Garfield MovieEducation24-hour clockEid al-AdhaGolden EdgeQueen (band)List of countries by continentsAviciiBig Mac IndexAdolf Hitler UunonaUmro Ayyar - A New BeginningMurder of Junko FurutaHelp:Authority controlCristiano RonaldoBismillahir Rahmanir Raheem19 Kids and CountingSOLID (object-oriented design)Jude BellinghamXXXTentacionLisa SparxxxPeriodic tableList of fruitsBTS