P
pete kirkham
As a result of doing a fibbonacci function example in C++, I wrote some
code for big integer addition that is 31 bit packed (not having 64bit
longs in the version of C++ I was using). The implementation of
BigInteger on Sun's and Apple's JVMs is 32 bit packed and casts to long
to allow the words to overflow, instead of using the high bit on 32bit
addition/subtraction. Basically, the 31 bit packed version does more,
less costly operations.
On Apple's 1.4.1 JVM on a G4:
For addition of small values, ~75% faster.
For addition of ~1000 digit values, ~35% faster.
For addition of ~10000 digit values, ~25% faster.
I would expect the performance gain to tail off as the number of digits
increases.
I would expect this method to be slower on an 64 bit JVM implementation,
should someone write one (it is word length dependant). Is the JVM for
the intel chip 64 bit?
Is there anyone out there who is doing addition/subtraction intensive
calculations in that range of digits on 32 bit machines that would want
to use it? If so, I'll write the other operations (subtraction will be
as good as addition; multiplication is likely to be slower by 1/32;
division I don't know without doing it as I'd play with the algorithm a
bit) and put it on sourceforge. Otherwise I'll play with a bit and
release it much later as part of (kin).
Pete
code for big integer addition that is 31 bit packed (not having 64bit
longs in the version of C++ I was using). The implementation of
BigInteger on Sun's and Apple's JVMs is 32 bit packed and casts to long
to allow the words to overflow, instead of using the high bit on 32bit
addition/subtraction. Basically, the 31 bit packed version does more,
less costly operations.
On Apple's 1.4.1 JVM on a G4:
For addition of small values, ~75% faster.
For addition of ~1000 digit values, ~35% faster.
For addition of ~10000 digit values, ~25% faster.
I would expect the performance gain to tail off as the number of digits
increases.
I would expect this method to be slower on an 64 bit JVM implementation,
should someone write one (it is word length dependant). Is the JVM for
the intel chip 64 bit?
Is there anyone out there who is doing addition/subtraction intensive
calculations in that range of digits on 32 bit machines that would want
to use it? If so, I'll write the other operations (subtraction will be
as good as addition; multiplication is likely to be slower by 1/32;
division I don't know without doing it as I'd play with the algorithm a
bit) and put it on sourceforge. Otherwise I'll play with a bit and
release it much later as part of (kin).
Pete