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

SOLR-16361 'mod' function query casts to float, returns wrong modulus for large ints #989

Merged
merged 9 commits into from
Sep 16, 2022

Conversation

danrosher
Copy link
Contributor

@danrosher danrosher commented Aug 30, 2022

https://issues.apache.org/jira/browse/SOLR-16361

Description

use double instead of float for mod function query

Solution

use double instead of float for mod function query

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

@danrosher danrosher changed the title SOLR-16361 SOLR-16361 'mod' function query casts to float, returns wrong modulus for large ints Aug 30, 2022
@epugh
Copy link
Contributor

epugh commented Aug 31, 2022

Any chance of a unit test demonstrating the problem? It looks like all reasonable Java code, but it would help me see the unit test demonstrating the problem, and then the fix!

@danrosher
Copy link
Contributor Author

Any chance of a unit test demonstrating the problem? It looks like all reasonable Java code, but it would help me see the unit test demonstrating the problem, and then the fix!

Added a large int cast to float and double to demonstrate the difference/issue, and a unit test for the new mod impl

Copy link
Contributor

@dsmiley dsmiley left a comment

Choose a reason for hiding this comment

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

Nice work! Can you add a CHANGES.txt entry under 9.1 improvements -- like "mod() is now accurate with even higher integers above 123456789"

@danrosher
Copy link
Contributor Author

Nice work! Can you add a CHANGES.txt entry under 9.1 improvements -- like "mod() is now accurate with even higher integers above 123456789"

Thanks! Added entry to CHANGES.txt

@epugh epugh merged commit b480bc8 into apache:main Sep 16, 2022
epugh pushed a commit that referenced this pull request Sep 16, 2022
… for large ints (#989)

* use double instead of float
Co-authored-by: Dan Rosher <d.rosher@cv-library.co.uk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants