question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
simonebcommented, Apr 18, 2022

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

0reactions
weijian-zhucommented, Apr 18, 2022

That sounds cool, but I still don’t know enough about it to know where to start

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found