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

Avoid IEEE-754 issues for multipleOf and divisibleBy #228

Merged

Conversation

spacebaboon
Copy link

@spacebaboon spacebaboon commented Aug 17, 2017

Refactor multipleOf and divisibleBy to perform integer calculations to avoid IEEE-754 float innacuracies.

Resolves #187

This was causing, e.g. 2.4 not to be a multipleOf 0.1.
The code multiplies by the minimum factor of 10 so that the modulo calculation is performed on integers.
The validator code refactored to avoid repetition between multipleOf and divisibleBy validations, which are the same but with different names and error messages.

All credit goes to @manahga for coming up with this solution 👍

…o avoid IEEE-754 float innacuracies.

This was causing, e.g. 2.4 not to be a multipleOf 0.1.
The code multiplies by the minimum factor of 10 so that the modulo calculation is performed on integers.
 All credit goes to @manahga for coming up with this solution.
@manahga
Copy link

manahga commented Aug 17, 2017

Thanks for making the changes for me @spacebaboon. I was just about to write back to tell you that I am a little swamped with work right now as well. Much Appreciated...

@tdegrunt tdegrunt merged commit 038fc52 into tdegrunt:master Aug 18, 2017
spacebaboon pushed a commit to spacebaboon/react-jsonschema-form that referenced this pull request Aug 18, 2017
Bump jsonschema dependency version to include fix to this issue.
Fixed by tdegrunt/jsonschema#228
No test changes here, the json schema validation tests are in jsonschema.
n1k0 pushed a commit to rjsf-team/react-jsonschema-form that referenced this pull request Aug 18, 2017
Bump jsonschema dependency version to include fix to this issue.
Fixed by tdegrunt/jsonschema#228
No test changes here, the json schema validation tests are in jsonschema.
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.

None yet

3 participants