I tried to make a program for counting "big number". For example numbers which contain like 50 or 100 digits. I decided to put those numbers in strings and use classic algorithm, which I learned at primary school in first grade.
e.g.
1 2 3 4
12364639 // number 1
+ 27452 // number 2
__________
12392091 // outcome
So in this case string seems ideal to me.
And my problem is, that I have to count the digits together one by one. And each digit is type char as I know. So how can I count together for example '1' + '2' and get '3'?
If you really just want to tackle the problem, one (possibly naïve, I've never done this) solution would be to convert them like this:
1 2 3 4 5
int intFromChar(char ch)
{
// make sure ch is a digit
return ch - '0';
}
This relies on the fact that character sets assign numbers continuous values from 0 to 9, so, whatever these values are, the difference from whatever number to 0 is always its own mathematical value.