-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Don't show unexpected decimals for range slider value #6699
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
Open
dimwight
wants to merge
4
commits into
getodk:master
Choose a base branch
from
dimwight:6424+
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's nothing special about a step size less than 1 as far as I can tell! Floating point precision issues can happen with any step sizes that involve decimal values. I don't know how likely this is but it would be possible to have a step size of 1.3, for example.
Have you been able to determine the underlying issue? I originally thought it was an arithmetic issue but looking at the example on the forum, I'm not sure about that anymore. Is it possible that we are calling
BigDecimal(double)
somewhere? If so, that could be the issue and we might need to callBigDecimal(string)
instead. See https://stackoverflow.com/questions/46828044/bigdecimal-not-giving-exact-output-in-javaI think that's the most likely culprit and that it can be fixed upstream of this method. If you determine that it is in fact an arithmetic issue, then the
setScale
approach may be appropriate. I think we'd want to use the scale of the stepsize instead of hardcoding it to 3, though.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for alerting me to the root cause of the issue being the
BigDecimal
created inRangeWidgetUtils
bygetActualValue
, which is currently called from bothRangeDecimalWidget
andRangeIntegerWidget
.Since the code of these classes is more or less identical, it can be pushed up into superclass
RangeBaseWidget
with a constructor parameter to switch the detail differences.This enables
getActualValue
just to pass through the float received from the slider, andsetUpActualValueLabel
can then be adjusted to suit.