1. 程式人生 > >JS 大整數相加

JS 大整數相加

http blue func pop htm .com mstr int ~~

function sumStrings(a,b){
var res=‘‘, c=0;
a = a.split(‘‘);
b = b.split(‘‘);
while (a.length || b.length || c){
c += ~~a.pop() + ~~b.pop();
res = c % 10 + res;
c = c>9;
}
var num = parseInt(res.replace(/^0+/,‘‘));
return num;
}

轉自:http://www.cnblogs.com/kindofblue/p/4672129.html

JS 大整數相加