[Issue 21767] Underflow reported as overflow

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Mar 25 14:47:24 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21767

ag0aep6g <ag0aep6g at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g at gmail.com

--- Comment #1 from ag0aep6g <ag0aep6g at gmail.com> ---
(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.

--


More information about the Digitalmars-d-bugs mailing list