-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Regression: Difference in float values #93535
Comments
Bisection points to the rollup #93352, which contains PR #90247. This looks like an issue of floating point precision, e.g. the decimal 2.3 isn't exactly representable as an @rustbot label regression-from-stable-to-nightly T-libs A-time A-floating-point searched nightlies: from nightly-2022-01-26 to nightly-2022-02-01 bisected with cargo-bisect-rustc v0.6.1Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --preserve -- test |
@SNCPlay42 Thank you for identifying the relevant PR. If this is intentional and improves accuracy, as seems to be the case, then I have no wish personally for this to be "fixed", though being a breaking change it should be documented in the release notes when the time comes. I'll have to go away and pick different values or something to work around it. |
Floating points numbers are very finicky. You should never try to compare them directly, you should instead use comparison with some tolerance. See the book of the |
Precision is exactly the reason this issue arises. The previous implementation was discarding a significant amount of precision, and the new one is to the best of my knowledge lossless. While rounding mode did indeed change from round-to-nearest to truncating, it is important to note that:
These are actual values stored in the f32 for two of the failing tests (https://www.h-schmidt.net/FloatConverter/IEEE754.html is a nice way to verify this):
And these are exactly the values the new implementation produces after truncating conversion. |
My
libpulse-binding
crate has a set of time handling functionality with some conversion based tests. Today's monthly automated CI run has alerted me that some of the tests are failing with the current nightly compiler. Specifically assertions are failing with slightly different floating point results than expected. It seems that a presumed regression/breaking-change/unexpected-change has snuck into the nightlies.I've determined that the nightly that introduced this difference is
nightly-2022-01-28
.Details here:
The text was updated successfully, but these errors were encountered: