There are for example two pointers:

char* a = "500"; char* b = "777"; 

The task will teach the computer to add them as numbers. The catch is that there may be an option:

 char* c = "99999999999999999999999999999999999999999999999999999999999999999999999"; 

I don't think it fits into standard types. How to be? Maybe there is some kind of library (preferably under Linux) for working with giant numbers?

I tried to write my class, I made a bunch of errors. I do not want to reinvent the wheel.

  • one
    And the GNU MP library will not save the father of Russian democracy? - alexlz

4 answers 4

This section is a long arithmetic .
Here it is written more and there are tasks with online verification.
Here are some examples.

    There is. This is Long Arithmetic. So look for libraries for this request. When I was in school, wrote such under Pascal.

    In Java and Ruby, by the way, they work with such numbers using standard tools.

    • And python - Dzhioev
    • Thank you, sent on the right path :). - Jakeroid
    • I tested python with one brow. I wrote on Ruby a program for calculating factorial 1000 and it is on python. In general, the python sleg. maybe he wrote something wrong. on hack it looks like (0..1000) .inject {| a, b | a * b} - Anton Lakotko

    Java BigInteger

      The question is certainly interesting, but it comes down to how to represent the CHAR array as an array of INT, and then break it into pieces with each of which work separately ....

      • <i> but it comes down to how to represent the CHAR array as an array of INT </ i> And why? In my opinion it is quite possible to work with the lines directly :-) Do not forget that CHAR is also a number :-) - gecube