I'm checking this in.

This fixes PR 27685, a bug in BigInteger.modPow.  I've put a test case
in Mauve.

Tom

2006-05-26  Tom Tromey  <[EMAIL PROTECTED]>

        PR classpath/27685:
        * java/math/BigInteger.java (modPow): Correctly handle negative
        exponent.

Index: java/math/BigInteger.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/math/BigInteger.java,v
retrieving revision 1.27
diff -u -r1.27 BigInteger.java
--- java/math/BigInteger.java   28 Feb 2006 18:04:37 -0000      1.27
+++ java/math/BigInteger.java   27 May 2006 02:08:21 -0000
@@ -1168,7 +1168,7 @@
       throw new ArithmeticException("non-positive modulo");
 
     if (exponent.isNegative())
-      return modInverse(m);
+      return modInverse(m).modPow(exponent.negate(), m);
     if (exponent.isOne())
       return mod(m);
 

Reply via email to