Skip to content

Commit 9d714e9

Browse files
committed
[js] Fix nqp::expmod with negative exponents
1 parent 8846ec3 commit 9d714e9

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/vm/js/nqp-runtime/bignum.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ op.expmod_I = function(a, b, c, type) {
119119

120120
let result = 1n;
121121

122+
123+
if (exponent < 0n && base != 1n) {
124+
return makeBI(type, 0n);
125+
}
126+
122127
base = base % modulus;
123128

124129
while (exponent > 0n) {

0 commit comments

Comments
 (0)