Skip to content

Commit

Permalink
Document behavior of {f32,f64}::{min,max} on NaN
Browse files Browse the repository at this point in the history
This is based on the documented behavior of cmath::{fmin,fmax}.  It is also
tested by existing unit tests in this module.
  • Loading branch information
mbrubeck committed Jun 1, 2015
1 parent 3e561f0 commit f44d287
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/libstd/num/f32.rs
Expand Up @@ -660,6 +660,8 @@ impl f32 {
///
/// assert_eq!(x.max(y), y);
/// ```
///
/// If one of the arguments is NaN, then the other argument is returned.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn max(self, other: f32) -> f32 {
Expand All @@ -674,6 +676,8 @@ impl f32 {
///
/// assert_eq!(x.min(y), x);
/// ```
///
/// If one of the arguments is NaN, then the other argument is returned.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn min(self, other: f32) -> f32 {
Expand Down
4 changes: 4 additions & 0 deletions src/libstd/num/f64.rs
Expand Up @@ -636,6 +636,8 @@ impl f64 {
///
/// assert_eq!(x.max(y), y);
/// ```
///
/// If one of the arguments is NaN, then the other argument is returned.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn max(self, other: f64) -> f64 {
Expand All @@ -650,6 +652,8 @@ impl f64 {
///
/// assert_eq!(x.min(y), x);
/// ```
///
/// If one of the arguments is NaN, then the other argument is returned.
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn min(self, other: f64) -> f64 {
Expand Down

0 comments on commit f44d287

Please sign in to comment.