from [email protected]
You can take advantage of data type int. That can deal any 9 digit number.
Now write a int adder function. Then read 9 digit at a time from input and rest of the execution
Carry will be either 0 or 1. Set carry =1 if s > 9 where s=n1+n2+c1
We can use a completely non numerical approach. Just treat all digit as a symbol.
Case $n1 in
0) case $n2 in
0) case $c1 in
0) s=0; c=0;;
1) s=1; c=0;;
esac;;
1) case $c1 in
0) s=1; c=0;;
1) s=2; c=0;;
esac;;
2) xxxx
3) xxxx
4) xxxx
5) xxxx
6) xxxx
7) xxxx
8) case $c1 in
0) s=8; c=0;;
1) s=9; c=0;;
esac;;
9) case $c1 in
0) s=9; c=0;;
1) s=0; c=1;;
esac;;
esac;;
1) case $n2 in
0) case $c1 in
Xxxxxxxx
Though this code of the function is over 400 line but each cycle will execute only 5-6 line of the code. I would recommend to measure the performance of this code.
Feel free to contact for more details.