JS 大整数相加

Posted time_on

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JS 大整数相加相关的知识,希望对你有一定的参考价值。

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

转自:实现大整数加法

以上是关于JS 大整数相加的主要内容,如果未能解决你的问题,请参考以下文章