mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
std.numeric: Always use Stein's algorithm for integral gcd()
This commit is contained in:
parent
b066ff3741
commit
1bbff45fc8
1 changed files with 1 additions and 14 deletions
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue