# operations on a big integer class

This topic is 3173 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I am an amateur programmer. I was interested in this problem I found to create a big integer class that can hold really big numbers. I attempted to make this class. Currently, I can do conditional operations on the numbers and addition, subtraction and multiplication operations. I put in some thought about how to divide 2 big numbers, but so far I have not made any significant progress. So I was wondering if anyone could give me some advice as to how I can tackle this problem. Any help is greatly appreciated. Thanks a lot

##### Share on other sites
I've done some work on this. Division is one of the hardest parts to tackle. A couple of suggestions I have is to look into math using two's compliment and bit shifts.

By implementing two's compliment math into your code, you can get subtraction pretty easily.

A bit shfit to the left effectively multiplies a number by 2 (x2 for each individual bit shift), shifting to the right by a single shift gives you the equivelent of dividing by two. This can also make multiplication faster if implemented correctly, because you can usually break it down to a series of shifts and adds.

If I remember correctly, I had to do a combination of subtraction and bit shifting to produce relatively fast division on large numbers. There was a lot of logic involved figuring out when and how much to shift and when to subtract. It was definately way more intensive that the other operations.

1. 1
Rutin
24
2. 2
JoeJ
20
3. 3
4. 4
5. 5

• 9
• 46
• 41
• 23
• 13
• ### Forum Statistics

• Total Topics
631749
• Total Posts
3002046
×