[502] in java-interest

home help back first fref pref prev next nref lref last post

Re: BigInteger class out there?

daemon@ATHENA.MIT.EDU (Michael Lorton)
Mon Jun 26 16:28:34 1995

Date: Mon, 26 Jun 1995 12:42:56 -0700
From: Michael Lorton <mlorton@eshop.com>
To: java-interest@java.Eng.Sun.COM, dylan@cs.washington.edu
In-Reply-To: Chuck McManis's message of Mon, 26 Jun 1995 11:38:38 -0700 <9506261838.AA14065@pepper.Eng.Sun.COM>

> Without operator overloading doing large integers is a bit more
> "clunky" than with it but the basic interface is:

Which brings us to my question: why no operator overloading in Java?

> 	VPInteger a = new VPInteger(278);	// 278 bit integer
> 	VPInteger b = new VPInteger(278);	// and another
> 	VPInteger c;
> 
> 	c = a.add(b);		// c <- a + b
> 	c = a.mul(b);		// c <- a * b;
> 	a.mul(c, b);		// c <- a * b (C already is allocated)

What does this mean?  That the VPInteger pointed to by c is reset to
a*b.  If so, I think this is *bad*.

Consider:

	VPInteger five = new VPInteger(16);
 	five.assign("5");
	VPInteger six = new VPInteger(16);
 	six.assign("5");

	VPInteger product = five;

	six.mul(product, five);

	Sys.out.println(five);  // prints out "30" !!

Better, I would think, to make VPIntegers immutable, like Strings.
After all, you have garbage collection.


M.
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com

home help back first fref pref prev next nref lref last post