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.
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Jaime OlivaresConnect With a Mentor Software ArchitectCommented:
If just want to add/subtract/compare, then I suggest this simple class, BigInt:
Good luck,
Have a look at:

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 :)
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

You might want to check out the Numeric Template Library (NTL) at http://www.shoup.net/ntl/ - it provides support for arbitrary lenght integers.
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.
jhshuklaConnect With a Mentor Commented:
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.
All Courses

From novice to tech pro — start learning today.