the case is:
pow(1.01, int.min);
because int.min == -int.min
Maybe the while loop should be put into pow(F, uint) instead of pow(F, int)
like the following:
pure nothrow F pow(F)(F x, int n)
{
if (n < 0)
{
return 1 / pow(x, cast(uint)(-n));
}
return pow(x, cast(uint)n);
}
Comment #1 by rinick — 2009-07-21T22:54:26Z
(In reply to comment #0)
> Maybe the while loop should be put into pow(F, uint) instead of pow(F, int)
> like the following:
what about:
pure nothrow F pow(F)(F x, int n) if (isFloatingPoint!(F))
{
if (n < 0)
return 1 / pow(x, cast(uint)(-n));
else
return pow(x, cast(uint)n);
}
pure nothrow F pow(F)(F x, uint n) // allow integer if n is uint
{
...
}
This also solve #2973