Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Arithmetic underflow
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Computer programming condition}} {{Redirect|Underflow|the condition of attempting to read an empty buffer|Buffer underrun}} <!-- Keep this note! Technical term, necessary for Wikipedia articles; don't assign for wiktionary --> The term '''arithmetic underflow''' (also '''floating-point underflow''', or just '''underflow''') is a condition in a [[computer program]] where the result of a calculation is a number of more precise absolute value than the computer can actually represent in [[Computer memory|memory]] on its [[central processing unit]] (CPU). Arithmetic underflow can occur when the true result of a [[Floating-point arithmetic|floating-point operation]] is smaller in magnitude (that is, closer to zero) than the smallest value representable as a [[normal number (computing)|normal]] floating-point number in the target [[Data type|datatype]].<ref>{{cite journal |last1=Coonen |first1=Jerome T. |s2cid=206445847 |title=An implementation guide to a proposed standard for floating-point arithmetic |journal=Computer |date=1980 |volume=13 |issue=1 |pages=68β79 |doi=10.1109/mc.1980.1653344}}</ref> Underflow can in part be regarded as negative [[Arithmetic overflow|overflow]] of the [[exponent]] of the floating-point value. For example, if the exponent part can represent values from −128 to 127, then a result with a value less than −128 may cause underflow. For integers, the term "integer underflow" typically refers to a special kind of [[integer overflow]] or ''integer wraparound'' condition whereby the result of subtraction would result in a value less than the minimum allowed for a given integer type, i.e. the ideal result was closer to negative infinity than the output type's representable value closest to negative infinity.<ref>{{cite web |url=https://cwe.mitre.org/data/definitions/191.html |title=CWE-191: Integer Underflow (Wrap or Wraparound) (3.1) |website=Common Weakness Enumeration}}</ref><ref>{{cite web |url=https://dzone.com/articles/overflow-and-underflow-data |title=Overflow And Underflow of Data Types in Java |website=DZone}}</ref><ref>{{cite web |url=https://medium.com/@taabishm2/integer-overflow-underflow-and-floating-point-imprecision-6ba869a99033 |title=Integer Overflow/Underflow and Floating Point Imprecision |last=Mir |first=Tabish |date=4 April 2017 |website=Medium}}</ref><ref>{{cite web |url=https://www.mozilla.org/en-US/security/advisories/mfsa2015-147/ |title=Integer underflow and buffer overflow processing MP4 metadata in libstagefright |website=Mozilla}}</ref><ref>{{cite web |url=https://developer.apple.com/library/content/documentation/Security/Conceptual/SecureCodingGuide/Articles/BufferOverflows.html#//apple_ref/doc/uid/TP40002577-SW7 |title=Avoiding Buffer Overflows and Underflows |website=Apple Developer}}</ref> ==Underflow gap== The interval between β''fminN'' and ''fminN'', where ''fminN'' is the smallest positive normal floating-point value, is called the underflow gap. This is because the size of this interval is many orders of magnitude larger than the distance between adjacent normal floating-point values just outside the gap. For instance, if the floating-point datatype can represent 20 [[bit]]s, the underflow gap is 2<sup>21</sup> times larger than the absolute distance between adjacent floating-point values just outside the gap.<ref>{{cite book |last1=Sun Microsystems |title=Numerical Computation Guide |date=2005 |publisher=Oracle |url=https://docs.oracle.com/cd/E19422-01/819-3693/ |accessdate=21 April 2018}}</ref> In older designs, the underflow gap had just one usable value, zero. When an underflow occurred, the true result was replaced by zero (either directly by the hardware, or by system software handling the primary underflow condition). This replacement is called "flush to zero". The 1984 edition of [[IEEE 754]] introduced [[subnormal numbers]]. The subnormal numbers (including zero) fill the underflow gap with values where the absolute distance between adjacent values is the same as for adjacent values just outside the underflow gap. This enables "gradual underflow", where a nearest subnormal value is used, just as a nearest normal value is used when possible. Even when using gradual underflow, the nearest value may be zero.<ref>{{cite journal |last1=Demmel |first1=James |title=Underflow and the Reliability of Numerical Software |journal=SIAM Journal on Scientific and Statistical Computing |date=1984 |volume=5 |issue=4 |pages=887β919 |doi=10.1137/0905062}}</ref> The absolute distance between adjacent floating-point values just outside the gap is called the [[machine epsilon]], typically characterized by the largest value whose sum with the value 1 will result in the answer with value 1 in that floating-point scheme.<ref>{{cite book |last1=Heath |first1=Michael T. |title=Scientific Computing |date=2002 |publisher=McGraw-Hill |location=New York |isbn=0-07-239910-4 |page=20 |edition=2nd}}</ref> This is the maximum value of <math>\epsilon</math> that satisfies <math>\operatorname{fl}(1 + \epsilon) = \operatorname{fl}(1)</math>, where <math>\operatorname{fl}</math> is a function which converts the real value into the floating-point representation. While the machine epsilon is not to be confused with the underflow level (assuming subnormal numbers), it is closely related. The machine epsilon is dependent on the number of bits which make up the [[significand]], whereas the underflow level depends on the number of digits which make up the exponent field. In most floating-point systems, the underflow level is smaller than the machine epsilon. ==Handling of underflow== The occurrence of an underflow may set a ("sticky") status bit, raise an exception, at the hardware level generate an interrupt, or may cause some combination of these effects. As specified in [[IEEE 754]], the underflow condition is only signaled if there is also a loss of precision. Typically this is determined as the final result being inexact. However, if the user is [[trap (computing)|trapping]] on underflow, this may happen regardless of consideration for loss of precision. The default handling in IEEE 754 for underflow (as well as other exceptions) is to record as a floating-point status that underflow has occurred. This is specified for the application-programming level, but often also interpreted as how to handle it at the hardware level. ==See also== * [[Denormal number]] * [[Floating-point arithmetic]] * [[IEEE 754]] * [[Integer overflow]] * [[Logarithmic number system]] * [[Machine epsilon]] * [[Normal number (computing)]] == References == {{Reflist}} {{DEFAULTSORT:Arithmetic Underflow}} [[Category:Computer arithmetic]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite book
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite web
(
edit
)
Template:Redirect
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)