diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2018-12-15 18:41:21 +0100 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2018-12-15 18:41:21 +0100 |
| commit | 967b1fc3b723117d57ff27417d811747b1bf1242 (patch) | |
| tree | e0c72ab809fa3996b829b8949e51d280308f3ddf /src/libstd | |
| parent | 0a1b2267e45ed0a5bdbfcbe522024729c8bd1387 (diff) | |
| download | rust-967b1fc3b723117d57ff27417d811747b1bf1242.tar.gz rust-967b1fc3b723117d57ff27417d811747b1bf1242.zip | |
Fix a small mistake regarding NaNs in a deprecation message
`max` on floats returns the other argument if one of them is NaN, which would be `0.0` in this case. This is unlike the C functions `fdim` and `fdimf` which return NaN if either of their arguments is NaN. https://doc.rust-lang.org/1.31.0/std/primitive.f32.html#method.max https://en.cppreference.com/w/c/numeric/math/fdim
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/f32.rs | 3 | ||||
| -rw-r--r-- | src/libstd/f64.rs | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 7d17aaf2f26..d0dd4d4adcb 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -550,7 +550,8 @@ impl f32 { #[inline] #[rustc_deprecated(since = "1.10.0", reason = "you probably meant `(self - other).abs()`: \ - this operation is `(self - other).max(0.0)` (also \ + this operation is `(self - other).max(0.0)` \ + except that `abs_sub` also propagates NaNs (also \ known as `fdimf` in C). If you truly need the positive \ difference, consider using that expression or the C function \ `fdimf`, depending on how you wish to handle NaN (please consider \ diff --git a/src/libstd/f64.rs b/src/libstd/f64.rs index c800763167f..9e627ec2042 100644 --- a/src/libstd/f64.rs +++ b/src/libstd/f64.rs @@ -491,7 +491,8 @@ impl f64 { #[inline] #[rustc_deprecated(since = "1.10.0", reason = "you probably meant `(self - other).abs()`: \ - this operation is `(self - other).max(0.0)` (also \ + this operation is `(self - other).max(0.0)` \ + except that `abs_sub` also propagates NaNs (also \ known as `fdim` in C). If you truly need the positive \ difference, consider using that expression or the C function \ `fdim`, depending on how you wish to handle NaN (please consider \ |
