[kaffe] Bug Report: BigInteger.toString() fails for large numbers

Alan Eliasen eliasen at mindspring.com
Mon Apr 19 20:21:02 PDT 2004

   I've also tested the BigInteger.toString() problem with the current CVS
trunk, and the problem remains.  Processing of the program simply terminates
silently upon calling BigInteger.toString().  Original problem report attached

   Are there limitations to the size numbers that can be processed with the
gmp libraries?  Or is this a limitation when used with kaffe only?


   I've been happily experimenting with using Kaffe to run my programming
language/calculating tool "Frink" : http://futureboy.homeip.net/frinkdocs/ in
order to get the high-performance integer performance of the GP library, but
I'm having some problems.

   I've compiled Kaffe with the GMP libraries on Linux (Red Hat 9).
Engine: Just-in-time v3   Version: 1.1.4   Java Version: 1.1
Note:  I compiled GMP with --disable-fft due to known bugs in the FFT
multiplication routines.

   When I try to calculate and display large integers (say, large Mersenne
primes, it works up to a point, and then large numbers, say, 2^13466917-1
simply don't get formatted at all by the toString() method.  Running the "top"
command shows that nothing's running, no exceptions are thrown, and the
program doesn't continue.

   Below is a sample program that illustrates the problem.  If you replace the
number 13466917 with a smaller number, it is displayed correctly.  This sample
works as expected (although bloody slow (15+ hours ?!) for the toString()
method in Sun's VMs.)

import java.math.BigInteger;

public class BigIntTest
   /** This calculates the (previously) largest-known Mersenne Prime,
       2^13466917 - 1 */
   public static void main(String[] args)
      BigInteger b = new BigInteger("2");

      BigInteger p = b.shiftLeft(13466917 - 1);
      System.out.println("Exponentiation complete");
      p = p.subtract(new BigInteger("1"));
      System.out.println("Subtraction complete");

      System.out.println("Formatting completed.");

  Alan Eliasen                 | "You cannot reason a person out of a
  eliasen at mindspring.com       |  position he did not reason himself
  http://futureboy.homeip.net/ |  into in the first place."
                               |     --Jonathan Swift

More information about the kaffe mailing list