Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(cbor): number precision error in decoding test #6115

Merged
merged 1 commit into from
Oct 15, 2024

Conversation

BlackAsLight
Copy link
Contributor

Fixes: https://github.com/denoland/std/actions/runs/11310597614/job/31455830417#step:4:1

Due to the way JavaScript numbers work, numbers past 2 ** 53 lose precision. Weirdly though sometimes when converting them to BigInts they may gain more precision than they originally had.

@BlackAsLight BlackAsLight requested a review from kt3k as a code owner October 13, 2024 12:15
@github-actions github-actions bot added the cbor label Oct 13, 2024
@BlackAsLight BlackAsLight changed the title fix: number precision bug in tests fix(cbor): number precision error in decoding test Oct 13, 2024
Copy link

codecov bot commented Oct 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.57%. Comparing base (3927872) to head (6960e91).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6115   +/-   ##
=======================================
  Coverage   96.56%   96.57%           
=======================================
  Files         534      534           
  Lines       40550    40550           
  Branches     6085     6085           
=======================================
+ Hits        39159    39163    +4     
+ Misses       1347     1343    -4     
  Partials       44       44           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@kt3k
Copy link
Member

kt3k commented Oct 15, 2024

BTW is it a good idea to show warnings or something when the input of encodeCbor is a number > Number.MAX_SAFE_INTEGER?

@kt3k kt3k merged commit bcc2c6b into denoland:main Oct 15, 2024
20 checks passed
@kt3k kt3k changed the title fix(cbor): number precision error in decoding test test(cbor): number precision error in decoding test Oct 15, 2024
@BlackAsLight BlackAsLight deleted the cbor_decoding_integer_test branch October 15, 2024 05:16
@BlackAsLight
Copy link
Contributor Author

BTW is it a good idea to show warnings or something when the input of encodeCbor is a number > Number.MAX_SAFE_INTEGER?

I don't think that's necessary as anyone who is working with numbers that big should be aware of how JavaScript reacts with it.

@kt3k
Copy link
Member

kt3k commented Oct 15, 2024

Fair enough

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants