Integer overflow: Difference between revisions

Content deleted Content added
Ligneus (talk | contribs)
Example: 1/100 = centi
Origin: Added link to signed integer explanation
Tags: Mobile edit Mobile web edit
Line 13:
: 128 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 number representations|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>
A "wrap around" corresponds to the fact, that e.g. if the addition of two positive integers produces an overflow, it may result in an unexpected result. For example with unsigned 32 bit integers, 4000000000u + 1000000000u = 705032704u.