Results 1 to 4 of 4
Thread: multiplying two objects
- 09-15-2011, 03:29 AM #1
Member
- Join Date
- Aug 2011
- Posts
- 5
- Rep Power
- 0
multiplying two objects
Thers a class called BigInt and it has a size and digit. size is the number of digits in the integer that is entered and digit is an array that holds the integer.
I have to write a method that multiplies them. I tried using two for loops to go through each index and multiply them. I think one of my problems is that im storing the product too soon or just wrong.
any help or a push in the right direction would be appreciated.
this is what i have so far
Java Code:// multiply two BigInts public BigInt times(BigInt other) { //Declare i and initialize carry int i,j, temp; int carry = 0; //create product object BigInt product = new BigInt(); //set size of product product.size = this.size + other.size; //Loops to run through elements of array and multiply for(i = this.size; i >= 0; i--) { for(j = other.size; j >= 0; j--) { temp = this.digit[i] * other.digit[j]; product.digit[i+j] = temp % 10; carry = temp / 10; System.out.println(i + " Temp is " + temp); System.out.println("sum.digit[" + i +"] is " + product.digit[i]); } } return product; }
-
Re: multiplying two objects
cross-posted: arrays - Java multiplying two BigInt objects - Stack Overflow
You were warned before about not cross-posting without notification, and yet you seemed to have completely ignored this request as well as all the replies (never replied to them) to your previous question a few weeks back. This is not a good way to start out here.
- 09-15-2011, 03:36 AM #3
Member
- Join Date
- Aug 2011
- Posts
- 5
- Rep Power
- 0
Re: multiplying two objects
theyre the same?
- 09-15-2011, 06:11 AM #4
Re: multiplying two objects
Cross posted
multiplying two objects (Beginning Java forum at JavaRanch)
db
Similar Threads
-
multiplying columns by row in 2d array
By HarlanEllisonOverDrive in forum New To JavaReplies: 0Last Post: 11-15-2010, 03:06 AM -
Method for multiplying two polynomials
By javaprgr in forum New To JavaReplies: 3Last Post: 09-23-2010, 08:40 AM -
Multiplying Values of an Array
By brmcdani in forum New To JavaReplies: 3Last Post: 02-06-2010, 04:00 AM -
Multiplying Variables
By rnavarro9 in forum New To JavaReplies: 4Last Post: 12-03-2009, 08:10 AM -
[SOLVED] Multiplying Objects Problme
By thelinuxguy in forum Advanced JavaReplies: 7Last Post: 05-07-2009, 05:19 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks