blob: 81c5da7c5bc99902e02db6d9de4eb1e390b5b829 [file] [log] [blame]
//@ runBigIntEnabled
let assert = {
sameValue: function(i, e, m) {
if (i !== e)
throw new Error(m);
}
}
function bigIntMod(x, y) {
return x % y;
}
noInline(bigIntMod);
for (let i = 0; i < 10000; i++) {
let r = bigIntMod(30n, 10n);
assert.sameValue(r, 0n, 30n + " % " + 10n + " = " + r);
}
function bigIntModFolding(x, y) {
let r = x % y;
return -r;
}
noInline(bigIntModFolding);
for (let i = 0; i < 10000; i++) {
let r = bigIntModFolding(10, 30);
assert.sameValue(r, -10, "-(" + 10 + " % " + 30 + ") = " + r);
}
let r = bigIntModFolding(10n, 30n);
assert.sameValue(r, -10n, "-(" + 10n + " % " + 30n + ") = " + r);