diff options
| author | Ralf Jung <post@ralfj.de> | 2023-09-19 10:06:22 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-09-19 20:13:04 +0200 |
| commit | 028c78c6c70eb4e9aaf67df1fe650c07209f32ea (patch) | |
| tree | 04508beab46111eae9785eb8836df83712213e7c /library | |
| parent | af78bae565e85b9c5698ee909af0652674eca6d4 (diff) | |
| download | rust-028c78c6c70eb4e9aaf67df1fe650c07209f32ea.tar.gz rust-028c78c6c70eb4e9aaf67df1fe650c07209f32ea.zip | |
explain mysterious addition in float minimum/maximum
Diffstat (limited to 'library')
| -rw-r--r-- | library/core/src/num/f32.rs | 1 | ||||
| -rw-r--r-- | library/core/src/num/f64.rs | 1 |
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 } } |
