-
Notifications
You must be signed in to change notification settings - Fork 353
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
test floating point casting better #1265
Conversation
tests/run-pass/floats.rs
Outdated
assert_eq!((u32::MAX-127) as f32 as u32, u32::MAX); // rounding loss | ||
assert_eq!((u32::MAX-128) as f32 as u32, u32::MAX-255); // rounding loss |
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.
@hanna-kruppe do these two (and the two "rounding loss" tests below) look like correct behavior to you? I experimentally determined these to be the closest to u32::MAX
where the output of the roundtrip cast changes.
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.
@jodysankey you also seem to know floating point encoding stuff quite well, would be nice if you could have a look.
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.
Yes, they look exactly right to me. These are transition points from "odd significant + slightly less than 0.5 ULP" (which gets rounded down to uint::MAX - 1 ULP) to "odd significant + 0.5 ULP" (which is rounded up, so saturation kicks in when casting back to integer).
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.
@hanna-kruppe I only understood half of that, but that half sounds good. ;) Thanks!
@bors r+ |
📌 Commit b8a817f has been approved by |
☀️ Test successful - checks-travis, status-appveyor |
No description provided.