Skip to content

Commit 78c526c

Browse files
fixing yet another bug (cf bug#334): ModularBigInteger.pow give wrong results for negative exponents
1 parent 4004342 commit 78c526c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

bignum/src/commonMain/kotlin/com/ionspin/kotlin/bignum/modular/ModularBigInteger.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,8 @@ class ModularBigInteger private constructor(
229229
var e = exponent
230230
return if (this.modulus == BigInteger.ONE) {
231231
creator.ZERO
232+
} else if (e < 0) {
233+
return inverse().pow(-e)
232234
} else {
233235
var residue = BigInteger.ONE
234236
var base = this.residue

0 commit comments

Comments
 (0)