Advertisement
Advertisement
| 04.23.2008 at 03:57AM PDT, ID: 23345997 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: |
void HugeInteger::add(const HugeInteger &bigNumber2)
{
//if both bigNumbers are positive or both are negative, add together
//else subtract because neg + pos and pos + neg needs to be subtracted
int carry = 0; //holds carry over
for (int loopSize = arraySize - 1; loopSize > 0; loopSize--) //add all but last digit in array
{
int temp = bigNumber[loopSize];
bigNumber[loopSize] = (temp + bigNumber2.bigNumber[loopSize] + carry) %10; //remainder
carry = (temp + bigNumber2.bigNumber[loopSize] + carry) / 10;
}//end for
}//end add function
void HugeInteger::subtract(const HugeInteger &bigNumber2)
{
//in progress
int borrow = 0;
for (int digitIndex = arraySize - 1; digitIndex > 0; digitIndex--)
{
//determine if first array integer needs a borrow value
if (bigNumber[digitIndex] < bigNumber2.bigNumber[digitIndex])
{
int temp = bigNumber[digitIndex];
bigNumber[digitIndex] = (temp + 10)
- bigNumber2.bigNumber[digitIndex]- borrow;
borrow = 1;
}//end if
else
{
int temp = bigNumber[digitIndex];
bigNumber[digitIndex] = temp - bigNumber2.bigNumber[digitIndex] - borrow;
borrow = 0;
}//end else
}//end for
}//end subtraction function
void HugeInteger::Multiply(const HugeInteger &bigNumber2)
{
//in progress
}//end multiply function
|