From f0fa65a9d5fa7b98834569c721a94a8087726450 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Sat, 8 Jul 2017 17:15:35 -0400 Subject: [PATCH 1/3] Fix float NaN pos/neg assumptions --- traits/src/float.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/traits/src/float.rs b/traits/src/float.rs index 757be87..db0d900 100644 --- a/traits/src/float.rs +++ b/traits/src/float.rs @@ -323,8 +323,8 @@ pub trait Float /// ``` fn signum(self) -> Self; - /// Returns `true` if `self` is positive, including `+0.0` and - /// `Float::infinity()`. + /// Returns `true` if `self` is positive, including `+0.0`, + /// `Float::infinity()`, and `f64::NAN` with newer versions of Rust. /// /// ``` /// use num_traits::Float; @@ -337,27 +337,25 @@ pub trait Float /// /// assert!(f.is_sign_positive()); /// assert!(!g.is_sign_positive()); - /// // Requires both tests to determine if is `NaN` - /// assert!(!nan.is_sign_positive() && !nan.is_sign_negative()); + /// assert!(!nan.is_sign_negative()); /// ``` fn is_sign_positive(self) -> bool; - /// Returns `true` if `self` is negative, including `-0.0` and - /// `Float::neg_infinity()`. + /// Returns `true` if `self` is negative, including `-0.0`, + /// `Float::neg_infinity()`, and `-f64::NAN` with newer versions of Rust. /// /// ``` /// use num_traits::Float; /// use std::f64; /// - /// let nan = f64::NAN; + /// let neg_nan: f64 = -f64::NAN; /// /// let f = 7.0; /// let g = -7.0; /// /// assert!(!f.is_sign_negative()); /// assert!(g.is_sign_negative()); - /// // Requires both tests to determine if is `NaN`. - /// assert!(!nan.is_sign_positive() && !nan.is_sign_negative()); + /// assert!(!neg_nan.is_sign_positive()); /// ``` fn is_sign_negative(self) -> bool; From aaa4ab357ff75722c2cd77120e68bc199132e316 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Sat, 8 Jul 2017 17:21:32 -0400 Subject: [PATCH 2/3] Clarify what "newer versions of Rust" applies to --- traits/src/float.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/traits/src/float.rs b/traits/src/float.rs index db0d900..ded82a9 100644 --- a/traits/src/float.rs +++ b/traits/src/float.rs @@ -324,7 +324,7 @@ pub trait Float fn signum(self) -> Self; /// Returns `true` if `self` is positive, including `+0.0`, - /// `Float::infinity()`, and `f64::NAN` with newer versions of Rust. + /// `Float::infinity()`, and with newer versions of Rust `f64::NAN`. /// /// ``` /// use num_traits::Float; @@ -342,7 +342,7 @@ pub trait Float fn is_sign_positive(self) -> bool; /// Returns `true` if `self` is negative, including `-0.0`, - /// `Float::neg_infinity()`, and `-f64::NAN` with newer versions of Rust. + /// `Float::neg_infinity()`, and with newer versions of Rust `-f64::NAN`. /// /// ``` /// use num_traits::Float; From 426034ba09995deb7afb686bec1fd5d3a4ab7e0c Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Sun, 9 Jul 2017 08:30:22 -0400 Subject: [PATCH 3/3] Switch doctests to match functions --- traits/src/float.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/traits/src/float.rs b/traits/src/float.rs index ded82a9..3c8779a 100644 --- a/traits/src/float.rs +++ b/traits/src/float.rs @@ -330,14 +330,14 @@ pub trait Float /// use num_traits::Float; /// use std::f64; /// - /// let nan: f64 = f64::NAN; + /// let neg_nan: f64 = -f64::NAN; /// /// let f = 7.0; /// let g = -7.0; /// /// assert!(f.is_sign_positive()); /// assert!(!g.is_sign_positive()); - /// assert!(!nan.is_sign_negative()); + /// assert!(!neg_nan.is_sign_positive()); /// ``` fn is_sign_positive(self) -> bool; @@ -348,14 +348,14 @@ pub trait Float /// use num_traits::Float; /// use std::f64; /// - /// let neg_nan: f64 = -f64::NAN; + /// let nan: f64 = f64::NAN; /// /// let f = 7.0; /// let g = -7.0; /// /// assert!(!f.is_sign_negative()); /// assert!(g.is_sign_negative()); - /// assert!(!neg_nan.is_sign_positive()); + /// assert!(!nan.is_sign_negative()); /// ``` fn is_sign_negative(self) -> bool;