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;
}

转自:实现大整数加法

posted on 2017-06-20 18:37  time_on  阅读(448)  评论(0编辑  收藏  举报