std.numeric: Always use Stein's algorithm for integral gcd()

This commit is contained in:
Iain Buclaw 2021-04-17 12:38:54 +02:00 committed by The Dlang Bot
parent b066ff3741
commit 1bbff45fc8

View file

@ -2931,6 +2931,7 @@ Params:
T = Any numerical type that supports the modulo operator `%`. If T = Any numerical type that supports the modulo operator `%`. If
bit-shifting `<<` and `>>` are also supported, Stein's algorithm will bit-shifting `<<` and `>>` are also supported, Stein's algorithm will
be used; otherwise, Euclid's algorithm is used as _a fallback. be used; otherwise, Euclid's algorithm is used as _a fallback.
Returns: Returns:
The greatest common divisor of the given arguments. The greatest common divisor of the given arguments.
*/ */
@ -2941,20 +2942,6 @@ if (isIntegral!T)
{ {
return gcd!(Unqual!T)(a, b); return gcd!(Unqual!T)(a, b);
} }
else version (DigitalMars)
{
static if (T.min < 0)
{
assert(a >= 0 && b >= 0);
}
while (b)
{
immutable t = b;
b = a % b;
a = t;
}
return a;
}
else else
{ {
if (a == 0) if (a == 0)