D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 21767 - Underflow reported as overflow
Summary: Underflow reported as overflow
Status: RESOLVED INVALID
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 trivial
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-25 11:28 UTC by Ate Eskola
Modified: 2021-03-25 17:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ate Eskola 2021-03-25 11:28:52 UTC
auto x = -1234890712367412347124895720349587;

Output:
app.d(1): Error: integer overflow

That is an underflow, not an overflow.
Comment 1 ag0aep6g 2021-03-25 14:47:24 UTC
(In reply to Ajieskola from comment #0)
> auto x = -1234890712367412347124895720349587;
> 
> Output:
> app.d(1): Error: integer overflow
> 
> That is an underflow, not an overflow.

It's overflow. Underflow is when a floating point value is too close to zero.

From <https://en.wikipedia.org/wiki/Integer_overflow>: "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 digits – either higher than the maximum or lower than the minimum representable value."

From <https://en.wikipedia.org/wiki/Arithmetic_underflow>: "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, or more broadly, integer wraparound."

Could call it "wraparound" in the error message to avoid confusion.
Comment 2 Ate Eskola 2021-03-25 17:15:51 UTC
Staying in standard terminology is good enough IMO. My misunderstanding.