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.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

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!

HugeInteger add(), subtract(), and multiply() not functioning correctly!

Tags: C++
Ok, here are my problems:
 the add() function is only adding positive numbers right now.  My subtract() function is not subtracting correctly if the this.number is smaller then the bigNumber2 nor does it care about isNegative at this point, and I am lost on multiply(completely lost).  I am getting confused alot as to how to implement this.  I have a class HugeInteger that takes in positive and negative integers and stores then in a 40 element array.  As of right now, my constructor, input and output are all functioning correctly.  So a -1234 is stored as 0 0 0 ,..., 0 0 0 1 2 3 4 with a bool flag isNegative, and 1234 is stored as 0 0 0 ,..., 0 0 0 1 2 3 4 with a bool flag !isNegative.

Here is my .h file:
#ifndef HUGEINTEGER_H
#define HUGEINTEGER_H

#include <iostream>

class HugeInteger
{
public:
      HugeInteger();      //constructor
      void input();      
      void output() const;
      
      void add(const HugeInteger &);
      void subtract(const HugeInteger &);
      void Multiply(const HugeInteger &);

      bool equalTo(const HugeInteger &);
      bool notEqualTo(const HugeInteger &);
      bool greaterThan(const HugeInteger &);
      bool greaterThanOrEqualTo(const HugeInteger &);
      bool lessThan(const HugeInteger &);
      bool lessThanOrEqualTo(const HugeInteger &);
      bool isZero();

private:
      bool isNegative;
      char line[41];
      int bigNumber[40];      //array to hone users inputted integer
      int const arraySize;      //const array size


};      //End class HugeInteger

#endif

Starting with my add() function problem.  my brain says if you are adding two positive or two negative numbers you add and if they are one of each you subtract.  but after that I get stuck.  do I send the addition to the subtract() function or do it in add, when it is done how do I tell it to handle whether the answer is negative or positive.  Here is my add(), subtract() and multiply() functions.
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
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: rebelcowgirl_73
Solution Provided By: josgood
Participating Experts: 2
Solution Grade: A
Views: 5
Translate:
Loading Advertisement...
04.23.2008 at 04:10AM PDT, ID: 21419287

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 04:15AM PDT, ID: 21419310

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 04:28AM PDT, ID: 21419373

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 04:44AM PDT, ID: 21419492

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 05:02AM PDT, ID: 21419631

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 05:29AM PDT, ID: 21419855

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 05:35AM PDT, ID: 21419901

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 05:37AM PDT, ID: 21419913

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 05:47AM PDT, ID: 21420013

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 07:38AM PDT, ID: 21421147

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 09:43AM PDT, ID: 21422691

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 10:36AM PDT, ID: 21423245

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 10:48AM PDT, ID: 21423369

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 11:02AM PDT, ID: 21423506

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 11:20AM PDT, ID: 21423677

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 11:50AM PDT, ID: 21423973

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 11:57AM PDT, ID: 21424051

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 12:07PM PDT, ID: 21424159

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 12:55PM PDT, ID: 21424674

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 12:58PM PDT, ID: 21424703

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 01:01PM PDT, ID: 21424728

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 02:52PM PDT, ID: 21425815

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 02:57PM PDT, ID: 21425858

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 03:19PM PDT, ID: 21426043

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 03:24PM PDT, ID: 21426085

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 03:27PM PDT, ID: 21426113

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 03:30PM PDT, ID: 21426133

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 03:38PM PDT, ID: 21426180

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 03:38PM PDT, ID: 21426185

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 03:41PM PDT, ID: 21426213

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 03:46PM PDT, ID: 21426246

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 03:55PM PDT, ID: 21426324

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 04:04PM PDT, ID: 21426380

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 04:26PM PDT, ID: 21426472

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 04:33PM PDT, ID: 21426496

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 04:59PM PDT, ID: 21426637

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 05:23PM PDT, ID: 21426730

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 05:49PM PDT, ID: 21426843

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 05:59PM PDT, ID: 21426878

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 06:48PM PDT, ID: 21427030

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 06:48PM PDT, ID: 21427034

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 06:55PM PDT, ID: 21427061

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.23.2008 at 07:28PM PDT, ID: 21427355

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 06:27AM PDT, ID: 21430540

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 07:00AM PDT, ID: 21430881

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 07:31AM PDT, ID: 21431241

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 07:54AM PDT, ID: 21431550

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 08:05AM PDT, ID: 21431684

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 08:30AM PDT, ID: 21431964

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 08:35AM PDT, ID: 21432025

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 08:48AM PDT, ID: 21432177

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 09:22AM PDT, ID: 21432582

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 09:35AM PDT, ID: 21432704

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 09:40AM PDT, ID: 21432752

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
04.24.2008 at 09:43AM PDT, ID: 21432782

All comments and solutions are available to Premium Service Members only.

Start