JS 大整数相加
2021-07-20 13:05
标签:return pop string blog cti .com http turn sum function sumStrings(a,b){ 转自:http://www.cnblogs.com/kindofblue/p/4672129.html JS 大整数相加 标签:return pop string blog cti .com http turn sum 原文地址:http://www.cnblogs.com/time-on/p/7055720.html
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;
}