This is the mail archive of the
java-patches@sourceware.cygnus.com
mailing list for the Java project.
Re: Patch: New support for java.math.BigInteger
- To: Warren Levy <warrenl at cygnus dot com>
- Subject: Re: Patch: New support for java.math.BigInteger
- From: Per Bothner <per at bothner dot com>
- Date: 04 Feb 2000 15:00:49 -0800
- Cc: java-patches at sourceware dot cygnus dot com
- References: <Pine.SOL.3.91.1000204141127.6070A-100000@fencer.cygnus.com>
Warren Levy <warrenl@cygnus.com> writes:
> I've just checked in code to handle java.math.BigInteger to sourceware's
> libgcj. This is a Pure Java solution and credit for this goes mostly to
> Per Bothner <per@bothner.com>. Per has let us use his MPN and IntNum
> classes from Kawa in libgcj.
One thing Warren didn't mention, which I think is kinda cool, is that
MPN is basically a Pure Java version of the libgmp low-level routines
(the mpn_* functions). In other words, it should be easy to write a
version that uses libgmp's highly tuned mpn_ functions instead.
There are some licensing and other issues so that we don't (at this
point at least) want to make that the default, but it would be nice
to set up a configure option to use libgmp instead of MPN.java.
(One caveat: Except for the configure stuff, it should be trivial
to plug in gmp pn 32-bit systems, On system where libgmp uses
64-bit "limbs" it is less obvious what to do.)
Perhaps writing the necesaary CNI glue plus the configure magic
might be a nice small project for a volunteer?
> There are still a few BigInteger methods I haven't implemented; they're
> listed at the end of BigInteger.java. Feel free to implement these if
> you wish. The vast majority of BigInteger functionality though has been
> checked in, so hammer away at it.
You can use the gnu.math.BitOps class to write the logical operations,
including bitCount.
The BigInteger(String) and BigInteger(String, int radix) constructors
should be easy to write using IntNum's valueOf methods.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/