Fix float NaN pos/neg assumptions

This commit is contained in:
Lee Bousfield 2017-07-08 17:15:35 -04:00
parent 8964c65f38
commit f0fa65a9d5
No known key found for this signature in database
GPG Key ID: C41F6504C1164209
1 changed files with 7 additions and 9 deletions

View File

@ -323,8 +323,8 @@ pub trait Float
/// ``` /// ```
fn signum(self) -> Self; fn signum(self) -> Self;
/// Returns `true` if `self` is positive, including `+0.0` and /// Returns `true` if `self` is positive, including `+0.0`,
/// `Float::infinity()`. /// `Float::infinity()`, and `f64::NAN` with newer versions of Rust.
/// ///
/// ``` /// ```
/// use num_traits::Float; /// use num_traits::Float;
@ -337,27 +337,25 @@ pub trait Float
/// ///
/// assert!(f.is_sign_positive()); /// assert!(f.is_sign_positive());
/// assert!(!g.is_sign_positive()); /// assert!(!g.is_sign_positive());
/// // Requires both tests to determine if is `NaN` /// assert!(!nan.is_sign_negative());
/// assert!(!nan.is_sign_positive() && !nan.is_sign_negative());
/// ``` /// ```
fn is_sign_positive(self) -> bool; fn is_sign_positive(self) -> bool;
/// Returns `true` if `self` is negative, including `-0.0` and /// Returns `true` if `self` is negative, including `-0.0`,
/// `Float::neg_infinity()`. /// `Float::neg_infinity()`, and `-f64::NAN` with newer versions of Rust.
/// ///
/// ``` /// ```
/// use num_traits::Float; /// use num_traits::Float;
/// use std::f64; /// use std::f64;
/// ///
/// let nan = f64::NAN; /// let neg_nan: f64 = -f64::NAN;
/// ///
/// let f = 7.0; /// let f = 7.0;
/// let g = -7.0; /// let g = -7.0;
/// ///
/// assert!(!f.is_sign_negative()); /// assert!(!f.is_sign_negative());
/// assert!(g.is_sign_negative()); /// assert!(g.is_sign_negative());
/// // Requires both tests to determine if is `NaN`. /// assert!(!neg_nan.is_sign_positive());
/// assert!(!nan.is_sign_positive() && !nan.is_sign_negative());
/// ``` /// ```
fn is_sign_negative(self) -> bool; fn is_sign_negative(self) -> bool;