-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Open
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.Category: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
Our documentation for impl Rem for {f16, f32, f64, f128}
says:
The remainder has the same sign as the dividend and is computed as:
x - (x / y).trunc() * y
.
But that's not true. E.g.:
fn main() {
let (x, y) = (11f64, 1.1f64);
assert_eq!(x - (x / y).trunc() * y, x % y);
//~^ PANIC
// assertion `left == right` failed
// left: 0.0
// right: 1.0999999999999992
}
This mismatch creates a hazard when trying to correctly encode algorithms that rely on this semantic.
This tripped me up, e.g., when authoring:
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-bugCategory: This is a bug.Category: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.