Skip to content

Commit

Permalink
Merge pull request #805 from litmit/master
Browse files Browse the repository at this point in the history
Fix xgcd for negative values
  • Loading branch information
josdejong committed Mar 6, 2017
2 parents 5d11f2e + a531715 commit 9709a50
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/function/arithmetic/xgcd.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function factory (type, config, load, typed) {

while (b) {
q = Math.floor(a / b);
r = a % b;
r = a - q*b;

t = x;
x = lastx - q * x;
Expand Down
3 changes: 1 addition & 2 deletions test/function/arithmetic/xgcd.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ describe('xgcd', function() {
assert.deepEqual(xgcd(65, math.bignumber(40)), [math.bignumber(5), math.bignumber(-3), math.bignumber(5)]);
});

// FIXME: xgcd for negative values
it.skip('should calculate xgcd for edge cases with negative values', function () {
it('should calculate xgcd for edge cases with negative values', function () {
assert.deepEqual([1, -2, 1], xgcd(2, 5));
assert.deepEqual([1, -2, -1], xgcd(2, -5));
assert.deepEqual([1, 2, 1], xgcd(-2, 5));
Expand Down

0 comments on commit 9709a50

Please sign in to comment.