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

Demonstrate wrapping with asIntN/asUintN Bigint static methods #2832

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

lionel-rowe
Copy link
Contributor

Description

Demonstrate wrapping with asIntN/asUintN Bigint static methods

Motivation

Current examples fail to demonstrate the main use case for asIntN and asUintN, namely wrapping. The number > max check in the function means the number will never wrap, so there's no point in calling asIntN/asUintN. Also, the check is buggy, given that it only checks the max and not the min (-1n doesn't fit in a u64, and -9223372036854775809n doesn't fit in an i64, yet neither would trigger the "Number doesn't fit" path).

Additional details

N/A

Related issues and pull requests

N/A

@lionel-rowe lionel-rowe requested a review from a team as a code owner August 31, 2024 03:23
@lionel-rowe lionel-rowe requested review from chrisdavidmills and removed request for a team August 31, 2024 03:23
@lionel-rowe lionel-rowe force-pushed the bigint-asintn-asuintn branch from cd19e90 to 39021dc Compare August 31, 2024 03:28
Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

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

Hi @lionel-rowe, and thanks for your contribution to MDN.

I've tested the examples — they work as advertised, and are the right size to fit into the live example widget.

I'd also like to get a comment on this from someone who knows more than me about JS language mechanics, like @Josh-Cena.

Copy link
Member

@Josh-Cena Josh-Cena left a comment

Choose a reason for hiding this comment

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

Yeah, this makes sense to me. Thanks

@Josh-Cena Josh-Cena merged commit 5d4d988 into mdn:main Sep 2, 2024
5 checks passed
Copy link

github-actions bot commented Sep 2, 2024

Congratulations on your first merged pull request. 🎉 Thank you for your contribution! Did you know we have a project board with high-impact contribution opportunities? We look forward to your next contribution.

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

Successfully merging this pull request may close these issues.

3 participants