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

GH-45250: [JS] Fix denominator precision loss and remove unnecessary safe integer check for fractional part #45251

Merged
merged 10 commits into from
Jan 22, 2025

Conversation

yaooqinn
Copy link
Member

@yaooqinn yaooqinn commented Jan 14, 2025

Rationale for this change

What changes are included in this PR?

This PR uses string constructor for bigint to calculate the power of 10 with scale as the exponent value of the expression.

To Fix precision loss like

> BigInt(10) ** BigInt(25);
10000000000000000000000000n
> BigInt(Math.pow(10, 25))
10000000000000000905969664n

Also, we remove the unnecessary safe integer check for the fraction part.

Are these changes tested?

add some unit tests

Are there any user-facing changes?

no

Copy link

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

See also:

@kou kou changed the title [GH-45250][JS] Fix denominator precision loss and remove unnecessary safe integer check for fractional part GH-45250: [JS] Fix denominator precision loss and remove unnecessary safe integer check for fractional part Jan 14, 2025
Copy link

⚠️ GitHub issue #45250 has been automatically assigned in GitHub to PR creator.

@github-actions github-actions bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Jan 17, 2025
js/src/util/bn.ts Outdated Show resolved Hide resolved
js/src/util/bn.ts Outdated Show resolved Hide resolved
js/src/util/bn.ts Outdated Show resolved Hide resolved
js/src/util/bn.ts Outdated Show resolved Hide resolved
js/src/util/bn.ts Outdated Show resolved Hide resolved
yaooqinn and others added 5 commits January 20, 2025 09:44
Co-authored-by: Paul Taylor <[email protected]>
Co-authored-by: Paul Taylor <[email protected]>
Co-authored-by: Paul Taylor <[email protected]>
Co-authored-by: Paul Taylor <[email protected]>
Co-authored-by: Paul Taylor <[email protected]>
@yaooqinn
Copy link
Member Author

Thank you @trxcllnt for the suggestion and approval.

Copy link
Member

@domoritz domoritz left a comment

Choose a reason for hiding this comment

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

Thank you!

@github-actions github-actions bot added awaiting merge Awaiting merge and removed awaiting committer review Awaiting committer review labels Jan 21, 2025
@trxcllnt trxcllnt added this to the 20.0.0 milestone Jan 22, 2025
@trxcllnt trxcllnt merged commit f8f17a5 into apache:main Jan 22, 2025
11 checks passed
Copy link

After merging your PR, Conbench analyzed the 4 benchmarking runs that have been run so far on merge-commit f8f17a5.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 20 possible false positives for unstable benchmarks that are known to sometimes produce them.

@yaooqinn yaooqinn deleted the bignum branch January 23, 2025 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants