-
Notifications
You must be signed in to change notification settings - Fork 213
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 <-> float conversion broken by #192 #197
Comments
I'm working on the issue |
Hmmm, my attempt to isolate this failed: #![feature(compiler_builtins_lib)]
#![feature(i128_type, test)]
extern crate test;
use test::black_box as b;
extern "C" {
pub fn __floatuntisf(i: u128) -> f32;
pub fn __floatuntidf(i: u128) -> f64;
pub fn __fixunssfti(f: f32) -> u128;
pub fn __fixunsdfti(f: f64) -> u128;
}
#[test]
fn float_int_conv() {
unsafe {
let l :u128 = b(432 << 100);
assert_eq!(__fixunssfti(__floatuntisf(l)), l);
assert_eq!(__fixunsdfti(__floatuntidf(l)), l);
}
} ... works fine. |
So I could reproduce the issue by doing |
Unsure if related, but I'm attempting to build the latest commit of rust and am getting
|
Oh indeed, it was more that master of rust is complaining about something to do with type conversions. I didn't read this issue carefully enough to realise it's exclusively about 128bit conversions. |
Does the problem still exist? I just added a bunch of integer to float tests that indicate all of them should work. |
@AaronKutch does it exist if you re-apply the changed by #192 (or just revert #198)? As it's years ago I have forgotten what the refactor was about, but it should not have broken anything. Maybe after the fix to rust-lang/rust#10184 this is fixed as well, but one can't know without running the tests with the refactor applied. |
I wish I had seen this refactor earlier, I will adapt it to the modern |
I figured out what the problem probably was with your refactor. You see, sometimes the integer being casted to is larger than the integer representing the float, and sometimes it is the other way around. Because of this, one or the other case would lose bits unless you accounted for both:
|
This has been fixed by #397. There are float conversion problems related to an LLVM bug, but that is tracked in another issues |
#192 seems to have broken conversion between 128 bit ints and floats (rust-lang/rust#44785):
cc @alexcrichton
The text was updated successfully, but these errors were encountered: