about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2023-09-19 20:23:21 +0200
committerGitHub <noreply@github.com>2023-09-19 20:23:21 +0200
commit1b862186a78a2718cf9e644a647e5ff7288a4149 (patch)
treef53c62cfadce592100a6f6f92a4a52a88d3f1d6f
parentc5f215af33604dc1fbaa71282238e61a899ceafc (diff)
parent028c78c6c70eb4e9aaf67df1fe650c07209f32ea (diff)
downloadrust-1b862186a78a2718cf9e644a647e5ff7288a4149.tar.gz
rust-1b862186a78a2718cf9e644a647e5ff7288a4149.zip
Rollup merge of #115958 - RalfJung:mystery-plus, r=Mark-Simulacrum,notriddle
explain mysterious addition in float minimum/maximum

Thanks to `@programmerjake` for mentioning this.
-rw-r--r--library/core/src/num/f32.rs1
-rw-r--r--library/core/src/num/f64.rs1
2 files changed, 2 insertions, 0 deletions
diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs
index 3144db19707..290f649f9ac 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 20833defc41..7569d2cd6ca 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
         }
     }