Integer overflow: Difference between revisions

Content deleted Content added
Inmate13 (talk | contribs)
mNo edit summary
rv: 256 values include the value 0, so 255 is the maximum
Line 6:
The [[register width]] of the processor determines the the range of values that can be represented. Typical [[Binary numeral system|binary]] register widths include:
 
: 8 bits (maximum representable value 256255),
: 16 bits (maximum representable value 65,536535),
: 32 bits (the most common width for personal computers [[as of 2005]], maximum representable value 4,294,967,296295),
: 64 bits (maximum representable value 18,446,744,073,709,551,616615),
: 128 bits.
: 128 bits (maximum representable value 340,282,366,920,938,463,463,374,607,431,768,211,456).
 
Since an arithmetic operation may produce a result larger than the maximum representable value, an potential error condition may result. In the [[C programming language]], for example, signed integer overflow causes [[undefined behavior]], although arithmetic on unsigned integers, however, is reduced [[modular arithmetic|modulo a power of two]], meaning that unsigned integers "wrap around" on overflow.