50 character long values addition

I would like to add 2 values each having 50 chars value in them. Like,

int a = 1542232154845421451787....upto 50 char
int b = 4545214787956231545451.....upto 50 char

Now if I add them and result will come more than that of INT/Double/Long bytes, I just want these two numbers to be added and store and then display the complete result on the screen without any overflow or any bound number of digits. How can I use these, is there any special data type for it.
vicky2kAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

udo_borkowskiCommented:
Have a look at:

http://www.swox.com/gmp/
0
ikeworkCommented:
why not using 64-bit-datatypes

if you are on windows use "__int64" or other systems: "signed long long" rather than int's


hope it helps :)
ike
0
jkrCommented:
You might want to check out the Numeric Template Library (NTL) at http://www.shoup.net/ntl/ - it provides support for arbitrary lenght integers.
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Jaime OlivaresSoftware ArchitectCommented:
If just want to add/subtract/compare, then I suggest this simple class, BigInt:
http://www.mathcs.richmond.edu/~hubbard/pwcpp/classes/bigint/bigint.h
http://www.mathcs.richmond.edu/~hubbard/pwcpp/classes/bigint/bigint.cc
Good luck,
Jaime.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vicky2kAuthor Commented:
Make a program in C++ and then tell me here the codes becuase I dont have enough time to understand the classes made for this, I need simple example like 2n+5n=615454545454545445 as long as number evaluated from calculations it should be printed on screen in full.
0
jhshuklaCommented:
sounds like a hw q. here's an outline/skeleton

char num1[50] = "000....00012345678901234567890", num2[50] = "000...00098765432109876543210";

add(char * result, const char * num1, const char * num2){
  memcpy(result, num1, 50*sizeof(char));
  for(i=49; i>=0; i--){
    result[i] += num2[i];
    if((result[i] - '0'*2) > 10){
      //do carry over operation
    }
  }
  cout << result; //need to take care of that 0-padding
}
I have given you the frame, now fill out the missing part and that should be it. In case you have question about '0'*2:
if you add '9' and '5' you get ('0'+9) + ('0'+5). subtracting 2*'0' will give you 14 and then you know that a carry over action is needed.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.