Parse Float has a rounding limit? How can I fix this?

前端 未结 3 1082
小鲜肉
小鲜肉 2021-01-18 00:08

I set up a system that parses a compact data string into JSON. I\'m using a 19 digit number to store ids. Unfortunately any number greater than 17 digits, parseFloat()

3条回答
  •  不知归路
    2021-01-18 00:30

    Numbers in JavaScript lose precision if they are higher than a certain value.

    According to http://www.hunlock.com/blogs/The_Complete_Javascript_Number_Reference, integers are only reliable up to 15 digits (9 * 10^15 to be exact).

提交回复
热议问题