Content deleted Content added
The case for correcting the definition of underflow. |
|||
Line 40:
Ouch! It should have been the other way around. Integer overflow is a special case of arithmetic overflow, which can also include float overflow (too large integer exponent, which again is a type of integer overflow, but is (or may be) handled differently for the exponents of floats (i.e. by assigning the special +Infinity and -Infinity values)).[[Special:Contributions/37.44.138.159|37.44.138.159]] ([[User talk:37.44.138.159|talk]]) 07:18, 25 August 2019 (UTC)
== Ambiguity Regarding underflow ==
The definition of integer underflow is incorrect. Integer overflow is the blanket term for where a value exceeds the range of an integer. When the maximum value is exceeded, this is positive overflow. When the minimum value is exceeded, this is negative overflow -- not underflow!
Integer underflow is a less remarkable example of information loss, where precision is lost due to an arithmetic operation such as integer division or bitwise right-shift, or due to a conversion from a type that can represent fractional values, e.g. floating-point. For example, where 3 / 2 = 1, we are seeing integer underflow.
The references to integer underflow are misleading. There will always be more examples of the misuse of the term integer underflow than examples of its correct use, because the proportion of material concerned with integer overflow far exceeds that concerned with integer underflow. Thus a picture is painted of a general consensus around the incorrect definition. Of the five citations, the first is an article CWE-191 which gets the definition of underflow wrong. The second has only one reference which is a broken link. The third has a mistake by its own definition (-1 is not a smaller absolute value than 0). The fourth, again, is using the wrong definition of integer underflow. The fifth begins by talking about buffer underflow and then continues the semantics into a section on integers.
The preceding wikipedia article [https://en.wikipedia.org/wiki/Arithmetic_underflow] gets the definition of integer overflow right and even describes the example from the third underflow article as integer overflow. (But then it scores an own goal by saying this is integer wraparound. Ouch!)
Some of these citations are great examples of the ambiguity and require only minor clean-up. However the conclusion the draw is wrong. In particular, the following sentence is factually wrong and should be amended from
When the term integer underflow is used, it means the ideal result was closer to minus infinity than the output type's representable value closest to minus infinity.
to:
When the term integer underflow is used, it is often taken to mean the ideal result was closer to minus infinity than the output type's representable value closest to minus infinity.
|