This is the mail archive of the java-patches@gcc.gnu.org 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]
Other format: [Raw text]

Re: BigInteger.modInverse() fix


-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160

On Monday 16 December 2002 19:02, Per Bothner wrote:
> Raif S. Naffah wrote:
> >>Not necessarirly.  I don't think canonicaliztion of small
> >>integers is required for correctness, just (space) effiency...
> >
> > ...and speed, for some numerical algorithms where modulo 2**32 is
> > enough.
>
> canonicalize "in place" (i.e. ignoring the looking in smallFixNums
> still converts the 1-word integers to use just the 'ival' field
> without the 'words' array.  The issue is whether the input
> BigInteger, after "normalization-in-place" is replace by the
> equivalent BigInteger in the smallFixNums array.

if the above is a question, then the answer is yes.  see lines #435, 436 
(after patch is applied).

>...  The later
> wouldn't change the algorithms used, just the identity of the
> objects used.

...unless as was the case, the code in some places was assuming that 
because one of the arguments was in canonical form, the other one was 
too.  this is not guarranteed to be the case.

in the test cases submitted to mauve, the second argument to the 
extended Euclide algorithm, ends up to be a small int but not in 
canonical form, the code assumed that .ival can be used; it ends up 
using '1' (the number of words representing the value), and everything 
crumbles from then on.


cheers;
rsn
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Que du magnifique

iD8DBQE9/ZSx+e1AKnsTRiERA+cmAJ9Kn1C/5Z/ls/pvKOJSTv875gtGXQCgl02c
fz418GZ6xDwgXf6w73/Y/Ro=
=c8Wv
-----END PGP SIGNATURE-----


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