StarFire_xm
  • 文章
  • 粉丝
  • 评论

数值精度问题处理

2025-06-01 10:01:510 次浏览0 次评论技能类型: js

npm i   Decimal  用于处理精度数据

new Decimal(item.branchCompanyPrice).mul(100).toNumber()


对于超大数值12345678912345 这种数字转字符串等使用: npm i  jsonBigInt

const JSONbig = jsonBigInt({
  storeAsString: true, // 将大数字转为字符串
  strict: true // 严格模式
});


    发表

    还没有评论哦,来抢个沙发吧!