473,473 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Huge Integer problem

1 New Member
I have to do the huge integer problem,
Create a class HugeInteger which use 40-element array
of digits to store integers as larg as 40 digits each.
Provide member functions input, output, add, subtract ?
The hugeinteger has a int*. So the array in the
hugeinteger has to be dynamically allocated in the
input function (which reads from a text file).

ok so one of the hugeintegers has to be a pointer
to a hugeinteger. The hugeinteger has to be allocated
IN input function.

I have NO CLUE how to use the hugeInteger pointer
with the input function. Like how do i get it to
allocate in the input function?
since a regular Hugeinteger and a pointer to a hugeinteger
will be using the same member function. Please please someone help me i've been working on this code for about 12 hours straight....
Feb 21 '12 #1
1 2042
weaknessforcats
9,208 Recognized Expert Moderator Expert
Do this problem in pieces.

First, write a main() with an array of 4 ints called H1, like for HugeInteger #1.
Second, add a second array of 4 int called H2
Third, add a third array of 4 int called Sum.
Fourth, hard code some values into H1 and H2. Initialize Sum to zeros.
Fifth, write a loop to add H1 to H2 and put the result in Sum. Don't forget that you will need an int for carry.
Sixth, Get this working.
Seventh, move the loop to function and pass in H1, H2 and Sum.
Eighth, get this working.
Ninth, create a struct and put H1 in the struct. Change the function to take a struct* argument, H2 and Sum.
Tenth, get this working.
Eleventh, move the function inside the struct. Remove the struct* argument.
Twelfth, verify everything is still working.
Thirteenth, make the H1 private and the member function public. Now chnage the word struct to class.
Fourteenth, verify everything still works.
Fifteenth, now change the arrays to 40 ints.
Sixteenth, verify the code still works.

From here you can add functionality in small increments. Follow the rule of do a little, debug then do a little more. Always be sure your code works before adding new features. This way your code is based on a previous version of itself that worked.

Let me know what happened.
Feb 21 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Lol McBride | last post by:
Hi all, I'm currently having problems with data returned from a MySQL database in as much as the data returned is of the form '(1,10,23,33,35,48)' i.e. a list variable holding 6 integers returned...
0
by: guf | last post by:
Hi All, I have SQL Server 2000 sp3, Windows 2000 Server. I have a database which is used by an application server. I do several important jobs a day in the application server and never access my...
8
by: Pat | last post by:
I am using VC++ 6.0 to develop my program. class A { Object *obj public: A() { obj=new Object ; } ; }
11
by: johnny | last post by:
Can anyone tell me what is wrong with the following code fragment? char a = x; char b = y; int result = strtol(&a, NULL, 10) + strtol(&b, NULL, 10); I got the same result using...
20
by: barbara | last post by:
Hi, all I have to read a binary data which is four bytes and I need to use the following function to deal with data: Private Function BIT(ByVal Val As UInt32, ByVal BitNum As UInt32) As...
3
by: monomaniac21 | last post by:
hi all i have a script that retrieves rows from a single table, rows are related to eachother and are retrieved by doing a series of while loops within while loops. bcos each row contains a text...
17
by: khajeddin | last post by:
the problem is: Create a class HugeInteger which use 40-element array of digits to store integers as larg as 40 digits each.Provide methods input, output, add, subtract how to add to arrays ?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.