Skip to content

GH-35067: [JavaScript] toString for signed BigNums - #35067

Merged
domoritz merged 7 commits into
apache:mainfrom
aljazerzen:js-bignum-signed
Apr 22, 2023
Merged

domoritz merged 7 commits into
apache:mainfrom
aljazerzen:js-bignum-signed

Conversation

@aljazerzen

@aljazerzen aljazerzen commented Apr 12, 2023 •

Copy link
Copy Markdown
Contributor

What changes are included in this PR?

Closes #22932

Basically, signed negative numbers were displayed as very large positive numbers.

Are these changes tested?

Yes, I've also added tests for bn.ts (BigNum) that was not tested before.

Are there any user-facing changes?

Negative numbers stored in BigNum will now be displayed as negative numbers instead of very large positive numbers.

Note that this change also affects decimals, because they are stored in BigNum as signed numbers. Decimals still don't convert to string correctly, because inserting the decimal dot is not implemented. Ref apache/arrow-js#100.

@aljazerzen aljazerzen changed the title GH- : [JS] toString for signed BigNums GH-35067 : [JS] toString for signed BigNums Apr 12, 2023
@github-actions

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #35067 has no components, please add labels for components.

@github-actions github-actions Bot added the awaiting review Awaiting review label Apr 12, 2023
@aljazerzen aljazerzen changed the title GH-35067 : [JS] toString for signed BigNums GH-35067: [JS] toString for signed BigNums Apr 12, 2023
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #35067 has no components, please add labels for components.

@aljazerzen aljazerzen changed the title GH-35067: [JS] toString for signed BigNums GH-35067: [JavaScript] toString for signed BigNums Apr 12, 2023
@github-actions

Copy link
Copy Markdown

⚠️ GitHub issue #35067 has no components, please add labels for components.

@trxcllnt trxcllnt left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me, thanks @aljazerzen!

@github-actions github-actions Bot added awaiting committer review Awaiting committer review and removed awaiting review Awaiting review labels Apr 12, 2023
Comment thread js/src/util/bn.ts Outdated
@aljazerzen

Copy link
Copy Markdown
Contributor Author

I've spent a little time trying to get tests to pass, but something strange is happening:

the bn-tests.ts are failing only on -t es5 -m umd. I've debugged it to the finding that in this line, a.signed is false, even though I've constructed a signed number or a decimal (which is signed).

It may be a problem with how these prototypes are assigning to each other, but that is beyond me.

@trxcllnt

Copy link
Copy Markdown
Contributor

@aljazerzen 99% sure closure is mangling too aggressively, and we need to do if(!a['signed']) to defeat it.

Comment thread js/src/util/bn.ts Outdated
Co-authored-by: Paul Taylor <178183+trxcllnt@users.noreply.github.com>
@aljazerzen

Copy link
Copy Markdown
Contributor Author

@domoritz can you review this? @trxcllnt can it be merged with only one approval?

@domoritz

Copy link
Copy Markdown
Member

One review is fine. We can merge this.

@aljazerzen

Copy link
Copy Markdown
Contributor Author

Great. Please go ahead, as I don't have the permissions.

@domoritz
domoritz merged commit a1403d4 into apache:main Apr 22, 2023
@domoritz domoritz added this to the 13.0.0 milestone Apr 22, 2023
@domoritz

Copy link
Copy Markdown
Member

Thank you. I had to get back to my computer to use the merge script.

@ursabot

ursabot commented Apr 23, 2023

Copy link
Copy Markdown

Benchmark runs are scheduled for baseline = 080a74c and contender = a1403d4. a1403d4 is a master commit associated with this PR. Results will be available as each benchmark for each run completes.
Conbench compare runs links:
[Finished ⬇️0.0% ⬆️0.0%] ec2-t3-xlarge-us-east-2
[Failed] test-mac-arm
[Finished ⬇️0.77% ⬆️0.0%] ursa-i9-9960x
[Finished ⬇️0.39% ⬆️0.03%] ursa-thinkcentre-m75q
Buildkite builds:
[Finished] a1403d46 ec2-t3-xlarge-us-east-2
[Failed] a1403d46 test-mac-arm
[Finished] a1403d46 ursa-i9-9960x
[Finished] a1403d46 ursa-thinkcentre-m75q
[Finished] 080a74c2 ec2-t3-xlarge-us-east-2
[Failed] 080a74c2 test-mac-arm
[Finished] 080a74c2 ursa-i9-9960x
[Finished] 080a74c2 ursa-thinkcentre-m75q
Supported benchmarks:
ec2-t3-xlarge-us-east-2: Supported benchmark langs: Python, R. Runs only benchmarks with cloud = True
test-mac-arm: Supported benchmark langs: C++, Python, R
ursa-i9-9960x: Supported benchmark langs: Python, R, JavaScript
ursa-thinkcentre-m75q: Supported benchmark langs: C++, Java

@ursabot

ursabot commented Apr 23, 2023

Copy link
Copy Markdown

['Python', 'R'] benchmarks have high level of regressions.
ursa-i9-9960x

liujiacheng777 pushed a commit to LoongArch-Python/arrow that referenced this pull request May 11, 2023
)

### What changes are included in this PR?

Closes apache#22932

Basically, signed negative numbers were displayed as very large positive numbers.

### Are these changes tested?

Yes, I've also added tests for `bn.ts` (BigNum) that was not tested before.

### Are there any user-facing changes?

Negative numbers stored in BigNum will now be displayed as negative numbers instead of very large positive numbers.

Note that this change also affects decimals, because they are stored in BigNum as signed numbers. Decimals still don't convert to string correctly, because inserting the decimal dot is not implemented. Ref #28804.
* Closes: apache#35067

Lead-authored-by: Aljaž Mur Eržen <aljaz.erzen@gmail.com>
Co-authored-by: Aljaž Mur Eržen <aljazerzen@users.noreply.github.com>
Co-authored-by: Paul Taylor <178183+trxcllnt@users.noreply.github.com>
Signed-off-by: Dominik Moritz <domoritz@gmail.com>
ArgusLi pushed a commit to Bit-Quill/arrow that referenced this pull request May 15, 2023
)

### What changes are included in this PR?

Closes apache#22932

Basically, signed negative numbers were displayed as very large positive numbers.

### Are these changes tested?

Yes, I've also added tests for `bn.ts` (BigNum) that was not tested before.

### Are there any user-facing changes?

Negative numbers stored in BigNum will now be displayed as negative numbers instead of very large positive numbers.

Note that this change also affects decimals, because they are stored in BigNum as signed numbers. Decimals still don't convert to string correctly, because inserting the decimal dot is not implemented. Ref #28804.
* Closes: apache#35067

Lead-authored-by: Aljaž Mur Eržen <aljaz.erzen@gmail.com>
Co-authored-by: Aljaž Mur Eržen <aljazerzen@users.noreply.github.com>
Co-authored-by: Paul Taylor <178183+trxcllnt@users.noreply.github.com>
Signed-off-by: Dominik Moritz <domoritz@gmail.com>
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.

[JS] decimal toString does not support negative values

4 participants