Calculate large decimals (more than 15 digits) in Javascript

后端 未结 1 1529
陌清茗
陌清茗 2021-01-24 06:14

As we know, Javascript has some issues (or features) with calculating decimal numbers. For example:

1条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-24 06:36

    I already answered this in the comment, but here's a demonstration. BigNumber will accept a number in string format for input.

    console.log(new BigNumber(0.1).plus("198.43092534959501"));

    0 讨论(0)
提交回复
热议问题