apiwowar
apiwowar

Reputation: 11

Java multiplying two BigInt objects

Theres a BigInt class and two objects num1 and num2. I have a lab assignment and i have to multiply num1 and num2. they can be an integer up to 50 digits. the class has a size and a 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 these two objects and returns the product. Im a little confused on how to start this. Ive seen examples where there are two loops and a base. I have no idea what the base would be used for.

any pointers in the right direction would be appreciated.

Upvotes: 1

Views: 662

Answers (1)

Eran Zimmerman Gonen
Eran Zimmerman Gonen

Reputation: 4507

I assume base is decimal / hexadecimal etc., for a more general implementation...

Generally, you need to use normal long multiplication, like learned in school.

Also note that the result could be up to 100 digits in length - if you just need the 50 least significant, you could optimize the long multiplication a bit (pretty much cut it in half).

Upvotes: 2

Related Questions