Integer overflow: Difference between revisions

Content deleted Content added
fixing all the bad i.e.'s with the correct e.g.'s
Undid revision 789863173 by Fredsmith2 (talk). Most or all of these were correctly "i.e.": refining the definition, not giving examples.
Line 3:
In [[computer programming]], an '''integer overflow''' 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 bits – either larger than the maximum or lower than the minimum representable value.
 
The most common result of an overflow is that the least significant representable bits of the result are stored; the result is said to ''wrap'' around the maximum (ei.ge. modulo power of two).
 
An overflow condition gives incorrect results and, particularly if the possibility has not been anticipated, can compromise a program's reliability and [[software security|security]].
 
On some processors like [[graphics processing unit]]s (GPUs) and [[digital signal processor]]s (DSPs) which support [[saturation arithmetic]], overflown results would be "clamped", ei.ge. set to the minimum or the maximum value in the representable range, rather that wrapped around.
 
== Origin ==
Line 85:
[[Computer emergency response team]] (CERT) developed the As-if Infinitely Ranged (AIR) integer model, a largely automated mechanism to eliminate integer overflow and truncation in C/C++ using run-time error handling.<ref>[http://www.cert.org/archive/pdf/09tn023.pdf As-if Infinitely Ranged Integer Model]</ref>
 
In [[computer graphics]] or [[signal processing]], it is typical to work on data that ranges from 0 to 1 or from −1 to 1. An example of this is a [[grayscale]] image where 0 represents black, 1 represents white, and values in-between represent varying shades of gray. One operation that one may want to support is brightening the image by multiplying every pixel by a constant. [[Saturated arithmetic]] allows one to just blindly multiply every [[pixel]] by that constant without worrying about overflow by just sticking to a reasonable outcome that all these pixels larger than 1 (ei.ge. [[high dynamic range imaging|"brighter than white"]]) just become white and all values "darker than black" just become black.
 
== Examples ==