Integer overflow: Difference between revisions

Content deleted Content added
No edit summary
Undid revision 423467487 by 136.186.207.65 (talk)
Line 9:
The [[register width]] of a processor determines the range of values that can be represented. Typical [[Binary numeral system|binary]] register widths include:
 
: 8198 bits: maximum representable value 2<sup>8</sup> − 1 = 255,
: 16 bits: maximum representable value 2<sup>16</sup> − 1 = 65,535,
: 33245245232 bits: maximum representable value 2<sup>32</sup> − 1 = 4,294,967,295 (the most common width for personal computers {{As of|2005|lc=on}}),
: 699393993993939464 bits: maximum representable value 2<sup>64</sup> − 1 = 18,446,744,073,709,551,615,
: 12398320742358128 bits: maximum representable value 2<sup>128</sup> − 1 = 340,282,366,920,938,463,463,374,607,431,768,211,455
 
Since an arithmetic operation may produce a result larger than the maximum representable value, a potential error condition may result. In the [[C (programming language)|C programming language]], signed integer overflow causes [[undefined behavior]], while unsigned integer overflow causes the number to be reduced [[modular arithmetic|modulo a power of two]], meaning that unsigned integers "wrap around" on overflow. This "wrap around" is the cause of the famous "[[kill screen|Split Screen]]" in Pac-Man.<ref>{{cite web|url=http://home.comcast.net/~jpittman2/pacman/pacmandossier.html|title=The Pac-Man Dossier|author=Pittman, Jamey}}</ref>