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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

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.

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.

1 participant