Skip to content

Commit

Permalink
gcd needs to abs both arguments before calculating
Browse files Browse the repository at this point in the history
  • Loading branch information
timo committed Jan 11, 2014
1 parent 17effc2 commit f2ce6f8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/interp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ void MVM_interp_run(MVMThreadContext *tc, void (*initial_invoke)(MVMThreadContex
cur_op += 4;
goto NEXT;
OP(gcd_i): {
MVMint64 a = GET_REG(cur_op, 2).i64, b = GET_REG(cur_op, 4).i64, c;
MVMint64 a = abs(GET_REG(cur_op, 2).i64), b = abs(GET_REG(cur_op, 4).i64), c;
while ( b != 0 ) {
c = a % b; a = b; b = c;
}
Expand Down

0 comments on commit f2ce6f8

Please sign in to comment.