[phobos] Fixing std.math.pow(x, int.min)
Don Clugston
dclugston at googlemail.com
Mon Jun 21 23:52:51 PDT 2010
On 22 June 2010 08:50, Lars Tandle Kyllingstad <lars at kyllingen.net> wrote:
> You're right, that works. Thanks!
>
> But may I ask _why_ it works? Consider:
>
> uint x = -int.min;
>
> My first guess would be that the result of the negation is an int as
> well (and therefore == int.min), and that the cast to uint doesn't
> happen until the assignment. Apparently this isn't the case.
-int.min is actually an unsigned result, that's why it wraps. Casting
it to uint unwraps it.
More information about the phobos
mailing list