Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Try getting bigint negative modulo working.
  • Loading branch information
jnthn committed Jun 22, 2013
1 parent d4a13c5 commit 231d1f2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/vm/jvm/runtime/org/perl6/nqp/runtime/Ops.java
Expand Up @@ -4221,7 +4221,15 @@ public static double div_In(SixModelObject a, SixModelObject b, ThreadContext tc
}

public static SixModelObject mod_I(SixModelObject a, SixModelObject b, SixModelObject type, ThreadContext tc) {
return makeBI(tc, type, getBI(tc, a).mod(getBI(tc, b)));
BigInteger divisor = getBI(tc, b);
if (divisor.compareTo(BigInteger.ZERO) < 0) {
BigInteger negDivisor = divisor.negate();
BigInteger res = getBI(tc, a).mod(negDivisor);
return makeBI(tc, type, res.equals(BigInteger.ZERO) ? res : divisor.add(res));
}
else {
return makeBI(tc, type, getBI(tc, a).mod(divisor));
}
}

public static SixModelObject expmod_I(SixModelObject a, SixModelObject b, SixModelObject c, SixModelObject type, ThreadContext tc) {
Expand Down

0 comments on commit 231d1f2

Please sign in to comment.