How to detect overflow

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Nov 4 02:06:47 PST 2015


On 11/04/2015 02:01 AM, Ola Fosheim Grøstad wrote:
> On Wednesday, 4 November 2015 at 08:18:00 UTC, Ali Çehreli wrote:
>> Thanks. I've noticed that the parameter of the subtraction functions
>> should be named 'underflow', no?
>
> Integer math cannot underflow, unless you define division to be
> equivalent to division over reals.
>
> overflow => higher/lower than max/min
>
> underflow => wrongly rounded to zero  (smaller than epsilon)
>
> Underflow can lead to unexpected division by zero errors in float
> expressions.

Thanks. It looks like I've been making stuff up on this page: :(

   http://ddili.org/ders/d.en/arithmetic.html

Ali



More information about the Digitalmars-d-learn mailing list