Index: C:/Documents and Settings/Imran/workspace2/math/src/main/java/java/math/BigInteger.java =================================================================== --- C:/Documents and Settings/Imran/workspace2/math/src/main/java/java/math/BigInteger.java (revision 575068) +++ C:/Documents and Settings/Imran/workspace2/math/src/main/java/java/math/BigInteger.java (working copy) @@ -684,14 +684,27 @@ if (exp < 0){ // math.16=Negative exponent throw new ArithmeticException(Messages.getString("math.16")); //$NON-NLS-1$ - } + } if (exp == 0) { return ONE; } else if(exp == 1 || equals(ONE) || equals(ZERO)) { return this; } + + // if even take out 2^x factor which we can + // calculate by shifting. + if(! testBit(0) ) + { + int x = 1; + BigInteger factor = BigInteger.ONE.shiftLeft(exp); + while(testBit(x) == false) + { + factor = factor.shiftLeft(exp); + x++; + } + return factor.multiply(this.shiftRight(x).pow(exp)); + } return Multiplication.pow(this, exp); - } /** @ar.org.fitc.spec_ref */