How to convert strings to bigInt in JavaScript

后端 未结 3 772
北海茫月
北海茫月 2021-02-05 19:25

I need to convert a string to BigInt like BigInteger in Javascript

Example

var reqId = \"78099864177253771992779766288266836166272662\";
var         


        
3条回答
  •  猫巷女王i
    2021-02-05 20:03

    You can use mathjs:

    var reqId = "78099864177253771992779766288266836166272662";
    var myBigNumber = math.bignumber(reqId);
    var res = math.add(myBigNumber, 1);
    console.log(myBigNumber.toString());
    // 7.8099864177253771992779766288266836166272662e+43
    console.log(res.toString());
    // 7.8099864177253771992779766288266836166272663e+43
    

提交回复
热议问题