Skip to content

Commit

Permalink
Merge pull request #7174 from crocopaw/gcd
Browse files Browse the repository at this point in the history
Fix issue 19514 - gcd(BigInt(2), BigInt(1)) fails
merged-on-behalf-of: Nicholas Wilson <thewilsonator@users.noreply.github.com>
  • Loading branch information
dlang-bot committed Sep 8, 2019
2 parents d3e9671 + a21bfbd commit cb4f35d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions std/numeric.d
Original file line number Diff line number Diff line change
Expand Up @@ -2734,6 +2734,8 @@ if (!isIntegral!T &&
shift++;
}

if ((a & 1) == 0) swap(a, b);

do
{
assert((a & 1) != 0);
Expand Down Expand Up @@ -2789,6 +2791,13 @@ if (!isIntegral!T &&
assert(gcd(CrippledInt(2310), CrippledInt(1309)) == CrippledInt(77));
}

// Issue 19514
@system pure unittest
{
import std.bigint : BigInt;
assert(gcd(BigInt(2), BigInt(1)) == BigInt(1));
}

// This is to make tweaking the speed/size vs. accuracy tradeoff easy,
// though floats seem accurate enough for all practical purposes, since
// they pass the "approxEqual(inverseFft(fft(arr)), arr)" test even for
Expand Down

0 comments on commit cb4f35d

Please sign in to comment.