Results 1 to 4 of 4
  1. #1
    apiwowar is offline Member
    Join Date
    Aug 2011
    Rep Power

    Default 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;

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default 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.

  3. #3
    apiwowar is offline Member
    Join Date
    Aug 2011
    Rep Power

    Default Re: multiplying two objects

    theyre the same?

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

Similar Threads

  1. multiplying columns by row in 2d array
    By HarlanEllisonOverDrive in forum New To Java
    Replies: 0
    Last Post: 11-15-2010, 04:06 AM
  2. Method for multiplying two polynomials
    By javaprgr in forum New To Java
    Replies: 3
    Last Post: 09-23-2010, 08:40 AM
  3. Multiplying Values of an Array
    By brmcdani in forum New To Java
    Replies: 3
    Last Post: 02-06-2010, 05:00 AM
  4. Multiplying Variables
    By rnavarro9 in forum New To Java
    Replies: 4
    Last Post: 12-03-2009, 09:10 AM
  5. [SOLVED] Multiplying Objects Problme
    By thelinuxguy in forum Advanced Java
    Replies: 7
    Last Post: 05-07-2009, 05:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts