diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index 3144db197074b..290f649f9acd6 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -957,6 +957,7 @@ impl f32 { } else if self == other { if self.is_sign_negative() && other.is_sign_positive() { self } else { other } } else { + // At least one input is NaN. Use `+` to perform NaN propagation and quieting. self + other } } diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index 20833defc41b8..7569d2cd6ca97 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -968,6 +968,7 @@ impl f64 { } else if self == other { if self.is_sign_negative() && other.is_sign_positive() { self } else { other } } else { + // At least one input is NaN. Use `+` to perform NaN propagation and quieting. self + other } }