-
-
Notifications
You must be signed in to change notification settings - Fork 99
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
Int to float conversion bug #84
Comments
Oh ... even worse:
|
Ideally we should try to reduce as much as possible floating point operations (https://rust-lang.github.io/rust-clippy/master/index.html#float_cmp). At the current stage we rely on floats on few validators (min, max, const and multipleOf), we might want to explore ways to have more accuracy without a big hit in performance. |
Indeed, I found multiple cases when was testing the Python bindings in #54 with Hypothesis - some of them are inevitable like |
In some numeric validators, we have a bug due to float conversion.
(1u64 << 54) - 1
is18014398509481983
and((2u64 << 53) - 1) as f64
is18014398509481984.0
which is +1. This causes various bugs on the corner cases:{"minimum": 18014398509481984u64}
should fail on18014398509481984u64 - 1
, because the latter is smaller. but it doesn't because the latter rounds to18014398509481984
and the validation fails. Interestingly that18014398509481984u64 - 2
doesn't fail and after the power of 53 we have these ranges that should fail but they don't:I.e with having the right part as the
minimum
value all values to the left part will pass validationThe text was updated successfully, but these errors were encountered: