Skip to content

Commit ddffe06

Browse files
RalfJungtgross35
authored andcommitted
clarify comments for min/max operations
1 parent eeaacad commit ddffe06

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/lib.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,10 @@ pub trait Float:
412412

413413
// IEEE-754R 5.7.2 General operations.
414414

415-
/// Implements IEEE minNum semantics. Returns the smaller of the 2 arguments if
416-
/// both are not NaN. If either argument is a NaN, returns the other argument.
415+
/// Implements IEEE 754-2008 `minNum` with the SNaN handling of IEEE 754-2019 `minimumNumber`.
416+
/// Returns the smaller of the 2 arguments if both are not NaN. If either argument is a NaN,
417+
/// returns the other argument. If both arguments are equal (in particular, if one is `-0.0` and
418+
/// `+0.0`), no guarantee is made about which one is returned.
417419
fn min(self, other: Self) -> Self {
418420
if self.is_nan() {
419421
other
@@ -426,8 +428,10 @@ pub trait Float:
426428
}
427429
}
428430

429-
/// Implements IEEE maxNum semantics. Returns the larger of the 2 arguments if
430-
/// both are not NaN. If either argument is a NaN, returns the other argument.
431+
/// Implements IEEE 754-2008 `maxNum` with the SNaN handling of IEEE 754-2019 `maximumNumber`.
432+
/// Returns the larger of the 2 arguments if both are not NaN. If either argument is a NaN,
433+
/// returns the other argument. If both arguments are equal (in particular, if one is `-0.0` and
434+
/// `+0.0`), no guarantee is made about which one is returned.
431435
fn max(self, other: Self) -> Self {
432436
if self.is_nan() {
433437
other
@@ -440,7 +444,7 @@ pub trait Float:
440444
}
441445
}
442446

443-
/// Implements IEEE 754-2018 minimum semantics. Returns the smaller of 2
447+
/// Implements IEEE 754-2019 `minimum` semantics. Returns the smaller of 2
444448
/// arguments, propagating NaNs and treating -0 as less than +0.
445449
fn minimum(self, other: Self) -> Self {
446450
if self.is_nan() {
@@ -460,7 +464,7 @@ pub trait Float:
460464
}
461465
}
462466

463-
/// Implements IEEE 754-2018 maximum semantics. Returns the larger of 2
467+
/// Implements IEEE 754-2019 `maximum` semantics. Returns the larger of 2
464468
/// arguments, propagating NaNs and treating -0 as less than +0.
465469
fn maximum(self, other: Self) -> Self {
466470
if self.is_nan() {

0 commit comments

Comments
 (0)