How to solve the problem of large integer accuracy
See original GitHub issue<script src="./msgpack.js"></script>
<script>
const { encode, decode } = msgpack5()
var buffer = encode({ num: 86699530287996692 })
var data = decode(buffer)
console.log(data) // => { num: 86699530287996690 }
</script>
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Losing My Precision: Tips For Handling Tricky Floating Point ...
Tip 1: Whenever possible, add numbers of similar small magnitude together before trying to add to larger magnitude numbers. Subtracting Numbers Of Similar ......
Read more >Accuracy and Precision
Solution. ... The extra precision of the other two numbers is not useful. ... The important question is “how big can the error...
Read more >python - Arithmetic precision problems with large numbers
1. Floating point numbers have limited precision. · 4. Python has arbitrary-precision integers but not arbitrary-precision real numbers. · Is ...
Read more >UsingWW: Large integer precision for math objects - WeBWorK
So far I'm just talking about getting the displayed answer to be right. It's a separate question about what precision you want to...
Read more >Precision loss with large numbers or non-integer values
Solution : Possible workarounds: When working with non-integer values, if you can make them integers with fewer than 15 digits, there will be...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You may want to check out how the Date codec is implemented, but I think the implementation for BigInt should be much simpler than that https://github.com/mcollina/msgpack5/blob/master/lib/codecs/DateCodec.js
That sounds cool, but I still don’t know enough about it to know where to start