Skip to content

Implement jl.Math.{multiplyFull, multiplyHigh, unsignedMultiplyHigh}. #5175

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

Merged
merged 2 commits into from
May 23, 2025

Conversation

sjrd
Copy link
Member

@sjrd sjrd commented May 19, 2025

JavaDocs starting at https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/lang/Math.html#multiplyFull(int,int)
multiplyFull and multiplyHigh were added in JDK 9. unsignedMultiplyHigh was added in JDK 18.

@sjrd sjrd requested a review from gzm0 May 19, 2025 15:48
@sjrd sjrd force-pushed the long-mul-hi branch 2 times, most recently from 87e5ed7 to 7569c24 Compare May 20, 2025 09:28
/* We fuzz-test by comparing to the "obvious" implementations based on
* BigIntegers. We use a SplittableRandom generator, because Random cannot
* generate all Long values.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Doing this in runtime concerns me, because it relies on our own BigInteger implementation for correctness (in fact, nothing seems to prevent our BigInteger implementation to rely on the math implementation here that we are testing).

Do you think we could just expand some test cases out? (Given the complexity of the method under test, I think 50 or 100 cases like above should be way enough).

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough. I'll expand the test cases.

@sjrd sjrd requested a review from gzm0 May 21, 2025 15:59
sjrd added 2 commits May 22, 2025 07:17
This way, we only have `require-jdk*` directories for JDK versions
that we actually test in our CI. They also correspond to JDK LTS
versions, so they are not arbitrary.
@gzm0 gzm0 merged commit f73a8ae into scala-js:main May 23, 2025
3 checks passed
@sjrd sjrd deleted the long-mul-hi branch May 23, 2025 11:14
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.

2 participants