Skip to content

Instantly share code, notes, and snippets.

@PlasmaPower
Created July 8, 2017 21:10
Show Gist options
  • Select an option

  • Save PlasmaPower/64d45a716407752d263b12dfd17a0e45 to your computer and use it in GitHub Desktop.

Select an option

Save PlasmaPower/64d45a716407752d263b12dfd17a0e45 to your computer and use it in GitHub Desktop.
diff --git a/traits/src/float.rs b/traits/src/float.rs
index 757be87..4bf8a70 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`.
///
/// ```
/// 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_positive() && !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`.
///
/// ```
/// 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() && neg_nan.is_sign_negative());
/// ```
fn is_sign_negative(self) -> bool;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment