BuiltinIntOperations { public static IntToken ediv(IntToken term1, IntToken term2, TermContext context) { try { return IntToken.of((term1.bigIntegerValue().signum() < 0 ? (term1.bigIntegerValue().add(BigInteger.ONE).subtract(term2.bigIntegerValue().abs())) : term1.bigIntegerValue()) .divide(term2.bigIntegerValue())); } catch (ArithmeticException e) { return null; } }  static IntToken add(IntToken term1, IntToken term2, TermContext context); static IntToken sub(IntToken term1, IntToken term2, TermContext context); static IntToken mul(IntToken term1, IntToken term2, TermContext context); static IntToken div(IntToken term1, IntToken term2, TermContext context); static IntToken ediv(IntToken term1, IntToken term2, TermContext context); static IntToken rem(IntToken term1, IntToken term2, TermContext context); static IntToken mod(IntToken term1, IntToken term2, TermContext context); static IntToken pow(IntToken term1, IntToken term2, TermContext context); static IntToken powmod(IntToken term1, IntToken term2, IntToken term3, TermContext context); static IntToken shl(IntToken term1, IntToken term2, TermContext context); static IntToken shr(IntToken term1, IntToken term2, TermContext context); static IntToken not(IntToken term, TermContext context); static IntToken and(IntToken term1, IntToken term2, TermContext context); static IntToken or(IntToken term1, IntToken term2, TermContext context); static IntToken xor(IntToken term1, IntToken term2, TermContext context); static IntToken min(IntToken term1, IntToken term2, TermContext context); static IntToken max(IntToken term1, IntToken term2, TermContext context); static IntToken abs(IntToken term, TermContext context); static IntToken log2(IntToken term, TermContext context); static BoolToken eq(IntToken term1, IntToken term2, TermContext context); static BoolToken ne(IntToken term1, IntToken term2, TermContext context); static BoolToken gt(IntToken term1, IntToken term2, TermContext context); static BoolToken ge(IntToken term1, IntToken term2, TermContext context); static BoolToken lt(IntToken term1, IntToken term2, TermContext context); static BoolToken le(IntToken term1, IntToken term2, TermContext context); static IntToken rand(IntToken upperBound, TermContext context);  }
@Test public void testediv() { testediv(-1, -1, 1, 0); testediv(7, 3, 2, 1); testediv(7, -3, -2, 1); testediv(-7, 3, -3, 2); testediv(-7, -3, 3, 2); testediv(123, 12, 10, 3); testediv(123, -12, -10, 3); testediv(-123, 12, -11, 9); testediv(-123, -12, 11, 9); testediv(123, 1233, 0, 123); testediv(123, -1233, 0, 123); testediv(-123, 1233, -1, 1110); testediv(-123, -1233, 1, 1110); }