Skip to content

Commit cee0bdd

Browse files
authored
Rollup merge of rust-lang#56857 - tbu-:pr_doc_abssub, r=zackmdavis
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
2 parents a777754 + 967b1fc commit cee0bdd

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/libstd/f32.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,8 @@ impl f32 {
550550
#[inline]
551551
#[rustc_deprecated(since = "1.10.0",
552552
reason = "you probably meant `(self - other).abs()`: \
553-
this operation is `(self - other).max(0.0)` (also \
553+
this operation is `(self - other).max(0.0)` \
554+
except that `abs_sub` also propagates NaNs (also \
554555
known as `fdimf` in C). If you truly need the positive \
555556
difference, consider using that expression or the C function \
556557
`fdimf`, depending on how you wish to handle NaN (please consider \

src/libstd/f64.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,8 @@ impl f64 {
491491
#[inline]
492492
#[rustc_deprecated(since = "1.10.0",
493493
reason = "you probably meant `(self - other).abs()`: \
494-
this operation is `(self - other).max(0.0)` (also \
494+
this operation is `(self - other).max(0.0)` \
495+
except that `abs_sub` also propagates NaNs (also \
495496
known as `fdim` in C). If you truly need the positive \
496497
difference, consider using that expression or the C function \
497498
`fdim`, depending on how you wish to handle NaN (please consider \

0 commit comments

Comments
 (0)