-
-
Notifications
You must be signed in to change notification settings - Fork 218
Add test for multipleOf to see if a library has problem with floating point rounding errors #68
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
Comments
python-jsonschema/jsonschema#185 and python-jsonschema/jsonschema#188 are related here. I'm unconvinced that this belongs here, and if it does, it almost certainly belongs in
So, if someone would like this test, I'd merge it, but only as an optional test, it's not mandatory, expected, or even reasonably-reliant behavior unless you control both ends as I understand the specifications (of jsonschema and of JSON). |
ok, I understand the problem and why the validation is correct, and using multipleOf is just wrong in my case. 13667*0.01 is 136.67000000000002 and not 136.67 as I thought naive. After reading https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency - I will use type string and regexp to validate for correct price representation in my schema. Thank you for your explanation. |
I agree with @Julian - test seems good, but should be in |
Hi,
please see: zaggino/z-schema#69
Using multipleOf can lead to wrong validation errors in some libraries which are written in
For example the following schema:
Validates correctly against the following documents:
But not against:
This is because rounding errors of floats in javascript (see http://floating-point-gui.de/):
Please add a test to validate agains this error case.
The text was updated successfully, but these errors were encountered: