This is the mail archive of the java-discuss@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: BigInteger.modPow bug? (was: Freenet compilation errors.)


On Thu, 11 Jan 2001, Boehm, Hans wrote:

> I'm also tracking down what appears to be a BigInteger bug, that might be
> related.  I'll keep you informed.  Please do the same.

No problem.  Last night I got it narrowed down to a problem in the private
divide method.  It seems that BigInteger.mod() is resulting in a (bogus)
negative value (the result should never be negative).  Using the debugger,
I found that the result of the divide done in the mod method was negative.

FWIW, This can be reproduced with the following:

public class EvilBug2 {
    public static void main(String[] args) {
        BigInteger Y = new
BigInteger("11031915393768328745374675758177209216362976918204400783769031961408
75500203838079438860704607120089946388490382313311206160357037199551472383943499
41968802357224177878230564379014395900786093465543114548034361805469457605783731
38257478798077195764061344762835117595916879801134306412390868834394415002870933
6");
        BigInteger Z = new
BigInteger("21145580999270356144540178884273434632387305495700605013558219015735
90017038827070721698806511595635875226688509595390524882971976105408404768726931
08381476249027986010074543599432542677282684917897250864056294311624311681558854
15843057440949108149021925690724390549654781387864088306495934634386588797138418
5");

        BigInteger res = Z.multiply(Z);
        System.out.println(res.mod(Y));
    }
}


Let me know what you find or if you think this is related to what you're
looking at.  I know that slight changes to either Z or Y make the negative
problem go away so that should help in homing in on the cause.

Right now, my debugger is being a bit finicky, so I haven't made much
progress today.
--warrenl




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]