Open
Description
I tried this code:
let numer = -0.7500000000000006f64;
let denom = 0.0833333333333334f64;
let div_euclid = -10.0;
let rem_euclid = 0.0;
assert_approx_eq!(numer.div_euclid(denom), div_euclid);
assert_approx_eq!(numer.rem_euclid(denom), rem_euclid);
assert_approx_eq!(div_euclid * denom + rem_euclid, numer - denom); // WRONG, should be numer
I expected to see this happen: div_euclid * denom + rem_euclid
should yield numer
. So either div_euclid
should yield -9.0
or rem_euclid
should yield 0.0833333333333334f64
. Together they should satisfy div_euclid * denom + rem_euclid == numer
.
Instead, this happened: div_euclid * denom + rem_euclid
yields numer - denom
. While both div_euclid
and rem_euclid
yield reasonable results in isolation, they are inconsistent which each other. The relation div_euclid * denom + rem_euclid == numer
is not satisfied.
Meta
rustc --version --verbose
:
rustc 1.68.0-nightly (4c83bd03a 2023-01-19)
binary: rustc
commit-hash: 4c83bd03a9d94af35c97a6b8b595d40e291af84a
commit-date: 2023-01-19
host: x86_64-unknown-linux-gnu
release: 1.68.0-nightly
LLVM version: 15.0.6