Skip to content

Commit 08962fc

Browse files
committed
allow long exponents in modular exponentiation
1 parent af1861c commit 08962fc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/main/java/de/tilman_neumann/jml/modular/ModularPower.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ public class ModularPower {
4545
}
4646

4747
/**
48-
* Computes a^b (mod c) for <code>a</code> BigInteger, <code>b, c</code> int. Very fast.
48+
* Computes a^b (mod c) for <code>a</code> BigInteger, <code>b</code> long, <code>c</code> int. Very fast.
4949
* @param a
5050
* @param b
5151
* @param c
5252
* @return a^b (mod c)
5353
*/
54-
public int modPow(BigInteger a, int b, int c) {
54+
public int modPow(BigInteger a, long b, int c) {
5555
// products need long precision
5656
long modPow = 1;
5757
long aModC = a.mod(BigInteger.valueOf(c)).longValue();
@@ -64,13 +64,13 @@ public int modPow(BigInteger a, int b, int c) {
6464
}
6565

6666
/**
67-
* Computes a^b (mod c) for all-int arguments. Very fast.
67+
* Computes a^b (mod c) for <code>a</code> int, <code>b</code> long, <code>c</code> int. Very fast.
6868
* @param a
6969
* @param b
7070
* @param c
7171
* @return a^b (mod c)
7272
*/
73-
public int modPow(int a, int b, int c) {
73+
public int modPow(int a, long b, int c) {
7474
// products need long precision
7575
long modPow = 1;
7676
long aModC = a % c;

0 commit comments

Comments
 (0)