You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#![feature(f16, f128)]fnmain(){let a = 1.2f16;let b = 1.1f32;let c = 1.1f64;let d = 1.1f128;println!("{} {} {} {}",(12f16).div_euclid(a)asf64,(11f32).div_euclid(b),(11f64).div_euclid(c),(11f128).div_euclid(d)asf64);println!("{} {} {} {}",(12f16).rem_euclid(a)asf64,(11f32).rem_euclid(b),(11f64).rem_euclid(c),(11f128).rem_euclid(d)asf64);}
I expected to see this happen:
All the 4 rem_euclid calls suggests .div_euclid should return 9 rather than 10.
I suspect the div_euclid for float type is buggy. For example, with (even correct) roundings, it is quite common that self < self.div_euclid(small_number) * small_number with rounding errors (which might not be expected.)
#![feature(float_next_up_down)]assert_eq!(1f64,1f64.next_down().div_euclid(1e-16)*1e-16);// pass, but this is not expected since the result 1f64 greater than the input `1f64.next_down()`
Maybe we should mark div_euclid/rem_euclid as at least unsafe, and perhaps we should also provide things like divmod which yields consist results so that self.divmod(thing).0 * thing + self.divmod(thing).1 == self always hold.
I tried this code:
I expected to see this happen:
All the 4
rem_euclid
calls suggests.div_euclid
should return 9 rather than 10.Instead, this happened:
All the 4
.div_euclid
calls yield 10.Meta
rustc --version --verbose
:Remark
I suspect the
div_euclid
for float type is buggy. For example, with (even correct) roundings, it is quite common thatself < self.div_euclid(small_number) * small_number
with rounding errors (which might not be expected.)Maybe we should mark div_euclid/rem_euclid as at least unsafe, and perhaps we should also provide things like
divmod
which yields consist results so that self.divmod(thing).0 * thing + self.divmod(thing).1 == self always hold.Tracking:
f16
andf128
float types #116909The text was updated successfully, but these errors were encountered: