Is there a limit in Javascript to decimal places on big floats?

后端 未结 1 1437
北恋
北恋 2020-12-07 05:20

I\'m facing the following issue/behavior:

console.log(1234567892012.123456);   // 1234567892012.1234
console.log(12345678920123.123456);  // 12345678920123.1         


        
相关标签:
1条回答
  • 2020-12-07 05:48

    Yes, you are seeing the inherent limitations of 64-bit floating point. If you really need more than two decimal places on a number as big as 123,456,789,201,234, you need some sort of extended arithmetic library. This question has some suggestions and discussion.

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