Bug 21767 – Underflow reported as overflow

Status
RESOLVED
Resolution
INVALID
Severity
trivial
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-03-25T11:28:52Z
Last change time
2021-03-25T17:15:51Z
Assigned to
No Owner
Creator
Ate Eskola

Comments

Comment #0 by Ajieskola — 2021-03-25T11:28:52Z
auto x = -1234890712367412347124895720349587; Output: app.d(1): Error: integer overflow That is an underflow, not an overflow.
Comment #1 by ag0aep6g — 2021-03-25T14:47:24Z
(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 by Ajieskola — 2021-03-25T17:15:51Z
Staying in standard terminology is good enough IMO. My misunderstanding.