Jump to content

Talk:Arithmetic underflow

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

An example could help the reader to understand this term better. If I understand the term right an underflow would occur when 11110000 and 0.0001111 are added on a floating-point computer with 4 significant digits. Please add this example if I am right or a better one.

That would be an example of round-off error, but this article now has a (correct) example. --PeR (talk) 16:12, 14 January 2008 (UTC)[reply]

Replaced most of the article with the FOLDOC entry, which is more clear, and has a good example. Vbucoci 10:17, 15 September 2006 (UTC)[reply]

Underflow not limited to floating point

[edit]

The article defines underflow as "the result of a calculation is a number of more precise absolute value than the computer can actually represent" and later elaborates "the true result of a floating point operation is smaller in magnitude (that is, closer to zero) than the smallest value representable [...]". I think the same could be applied to fixed point numbers. For example dividing 16 bit fixed point mantissa 0x0001 by two also results in a mantissa smaller in magnitude (that is, closer to zero) than the smallest value representable (provided the fixed point exponent cannot be changed, e.g., because we also have to represent larger fixed point mantissas like 0x7fff with the same exponent).

Therefore, while the floating point example is a reasonable illustration the statement in the article "The term underflow normally refers to floating point numbers only" is surprising. At least it is provided without any references. May be any term normally refers to floating point numbers because most people are never using anything else than floating point numbers?

Of course, we have do distinguish from overflow, which is discussed in this context and is mainly an integer and fixed point issue. --153.96.175.18 (talk) 11:21, 29 March 2022 (UTC)[reply]

To explain this context needs to be understood of what is the boundary.
An overflow occurs when bits are changed outside of a boundary.
Signed Integers overflow occurs when the bits representing the number cross their boundary and change the bit representing the sign.
Note: The representation of the data type doesnt matter as crossing the boundary is the problem. So the number being negative or positive doesn't matter.
As for another example, a stack overflow occurs when the call stack is so long it overflows into another part of the memory. A theoritical stack underflow could occur from backing out the stack without zeroing it. Then moving forward again having a improper stack location with new allocations and old allocations. This although isn't a thing.
So overflow is corruption outside a boundaries. Underflow is corruption inside a boundaries.
All arithmetic data types other than floating point do not have arithmetic operations that can cause corruption within their bit boundaries. 24.112.251.203 (talk) 07:40, 12 June 2025 (UTC)[reply]

Uncited claims that "underflow" refers exclusively to floating point values

[edit]

This article makes some rather bold claims and provides no citations to justify those claims (to which I've added "citation needed"):

Storing values that are too low in an integer variable (e.g., attempting to store −1 in an unsigned integer) is properly referred to as integer overflow[citation needed], or more broadly, integer wraparound. The term underflow normally refers to floating point numbers only, which is a separate issue.

I would argue that "integer underflow" has well-established usage describe this condition as can be substantiated from first-party sources: https://cwe.mitre.org/data/definitions/191.html

I noticed this claim on the Integer overflow page:

The term underflow is most commonly used for floating-point math and not for integer math.[4] However, many references can be found to integer underflow.[5][6][7][8][9]

It provides 5 citations for "integer underflow", and only one source claiming that "underflow" does not apply to integer math. What was the [4] source making such a claim, in disagreement with the others? Why, it's this very article on Arithmetic underflow! This feels like a definition that only comes from a Wikipedia game of telephone, not from a first-party source.

Unless it is updated with any citation whatsoever to substantiate its rather bold claim, I think the original language should be removed as it's unverifiable via a first-party source.

Tarcieri (talk) 14:11, 6 December 2023 (UTC)[reply]

This unfortunately is not a bold claim. The citations provided for Integer Underflow are all very poor. More or less just by reading the citations they can be disqualified. 24.112.251.203 (talk) 06:46, 12 June 2025 (UTC)[reply]

Improper citations for integer underflow

[edit]

There are multiple citations given for the integer underflow. These citations are not from quality sources, but rather engineer bloggers or bug reports that improperly use the term. The CWE citation is circular without defining or using the term. The Apple is a improper section title that also does not use or define the term.

The term overflow is referring to the bits not the representation of that data.

In signed integers the sign bit is the first bit counting from the left. The remaining bits are the number. Math operations on the bits can cause bits to the left to change. If the operation on the number bits overflows it change bits outside of it's boundary.

This has nothing to do with the number being positive or negative. The overflow is on the data structure's boundary. 24.112.251.203 (talk) 05:44, 12 June 2025 (UTC)[reply]

Iterating over the citations.
"CWE-191: Integer Underflow (Wrap or Wraparound) (3.1)"
This references a book called 24 Deadly Sins of Software Security.
In this book page 120 it references CWE-191.
Creating a circular reference.
The book does not define Integer underflow.
The two examples given by CWE are invalid.
Example 1. This is a classic overflow example.
Example 2. This is a invalid cast example. 24.112.251.203 (talk) 06:07, 12 June 2025 (UTC)[reply]
https://dzone.com/articles/overflow-and-underflow-data
This citation is from a freelance blogger with only 8 technical articles and no listed qualifications in computer science. 24.112.251.203 (talk) 06:12, 12 June 2025 (UTC)[reply]
https://medium.com/@jollyfish/integer-overflow-underflow-and-floating-point-imprecision-6ba869a99033
This is another small blogger with less than 10 posts.
Notably this article defines Integer underflow by citing https://en.m.wikipedia.org/wiki/IEEE_754
The citation is for floating point not Integers. 24.112.251.203 (talk) 06:18, 12 June 2025 (UTC)[reply]
https://www.mozilla.org/en-US/security/advisories/mfsa2015-147/
This is a bug report and patch. It is unclear if the term Integer Underflow is initiated by a developer or bug reporter.
This bug although had nothing to do with integers. The problem was reading from array positions. The fix of this bug is to ensure proper boundary check of the array. 24.112.251.203 (talk) 06:31, 12 June 2025 (UTC)[reply]
https://developer.apple.com/library/archive/documentation/Security/Conceptual/SecureCodingGuide/Articles/BufferOverflows.html#//apple_ref/doc/uid/TP40002577-SW7
Has a section called: "Avoiding Integer Overflows and Underflows"
This section defines Integer overflows specifically. Integer Underflows are not mentioned in the section or defined. 24.112.251.203 (talk) 06:43, 12 June 2025 (UTC)[reply]