Signed integer overflow undefined behavior or not?

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 13 04:40:00 PST 2015


On Friday, 13 November 2015 at 12:06:43 UTC, Matthias Bentrup 
wrote:
> On Friday, 13 November 2015 at 09:33:51 UTC, John Colvin wrote:
>> unsigned: f(v) = v mod 2^n - 1
>> signed: f(v) = ((v + 2^(n-1)) mod (2^n - 1)) - 2^(n-1)
>
> I guess you meant mod 2^n in both cases...

haha, yes, sorry.


More information about the Digitalmars-d mailing list