@@ -505,8 +505,7 @@ pub trait FloatCore: Num + NumCast + Neg<Output = Self> + PartialOrd + Copy {
505505 }
506506
507507 /// Returns `true` if `self` is positive, including `+0.0` and
508- /// `FloatCore::infinity()`, and since Rust 1.20 also
509- /// `FloatCore::nan()`.
508+ /// `FloatCore::infinity()`, and `FloatCore::nan()`.
510509 ///
511510 /// # Examples
512511 ///
@@ -524,6 +523,7 @@ pub trait FloatCore: Num + NumCast + Neg<Output = Self> + PartialOrd + Copy {
524523 /// check(-0.0f64, false);
525524 /// check(f64::NEG_INFINITY, false);
526525 /// check(f64::MIN_POSITIVE, true);
526+ /// check(f64::NAN, true);
527527 /// check(-f64::NAN, false);
528528 /// ```
529529 #[ inline]
@@ -532,8 +532,7 @@ pub trait FloatCore: Num + NumCast + Neg<Output = Self> + PartialOrd + Copy {
532532 }
533533
534534 /// Returns `true` if `self` is negative, including `-0.0` and
535- /// `FloatCore::neg_infinity()`, and since Rust 1.20 also
536- /// `-FloatCore::nan()`.
535+ /// `FloatCore::neg_infinity()`, and `-FloatCore::nan()`.
537536 ///
538537 /// # Examples
539538 ///
@@ -552,6 +551,7 @@ pub trait FloatCore: Num + NumCast + Neg<Output = Self> + PartialOrd + Copy {
552551 /// check(f64::NEG_INFINITY, true);
553552 /// check(f64::MIN_POSITIVE, false);
554553 /// check(f64::NAN, false);
554+ /// check(-f64::NAN, true);
555555 /// ```
556556 #[ inline]
557557 fn is_sign_negative ( self ) -> bool {
@@ -1263,38 +1263,42 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
12631263 fn signum ( self ) -> Self ;
12641264
12651265 /// Returns `true` if `self` is positive, including `+0.0`,
1266- /// `Float::infinity()`, and since Rust 1.20 also `Float::nan()`.
1266+ /// `Float::infinity()`, and `Float::nan()`.
12671267 ///
12681268 /// ```
12691269 /// use num_traits::Float;
12701270 /// use std::f64;
12711271 ///
1272+ /// let nan: f64 = f64::NAN;
12721273 /// let neg_nan: f64 = -f64::NAN;
12731274 ///
12741275 /// let f = 7.0;
12751276 /// let g = -7.0;
12761277 ///
12771278 /// assert!(f.is_sign_positive());
12781279 /// assert!(!g.is_sign_positive());
1280+ /// assert!(nan.is_sign_positive());
12791281 /// assert!(!neg_nan.is_sign_positive());
12801282 /// ```
12811283 fn is_sign_positive ( self ) -> bool ;
12821284
12831285 /// Returns `true` if `self` is negative, including `-0.0`,
1284- /// `Float::neg_infinity()`, and since Rust 1.20 also `-Float::nan()`.
1286+ /// `Float::neg_infinity()`, and `-Float::nan()`.
12851287 ///
12861288 /// ```
12871289 /// use num_traits::Float;
12881290 /// use std::f64;
12891291 ///
12901292 /// let nan: f64 = f64::NAN;
1293+ /// let neg_nan: f64 = -f64::NAN;
12911294 ///
12921295 /// let f = 7.0;
12931296 /// let g = -7.0;
12941297 ///
12951298 /// assert!(!f.is_sign_negative());
12961299 /// assert!(g.is_sign_negative());
12971300 /// assert!(!nan.is_sign_negative());
1301+ /// assert!(neg_nan.is_sign_negative());
12981302 /// ```
12991303 fn is_sign_negative ( self ) -> bool ;
13001304
@@ -2324,9 +2328,8 @@ mod tests {
23242328 assert_eq ! ( n, Float :: copysign( n, n) ) ;
23252329 assert_eq ! ( n. neg( ) , Float :: copysign( n, p) ) ;
23262330
2327- // FIXME: is_sign... only works on NaN starting in Rust 1.20
2328- // assert!(Float::copysign(nan, p).is_sign_positive());
2329- // assert!(Float::copysign(nan, n).is_sign_negative());
2331+ assert ! ( Float :: copysign( nan, p) . is_sign_positive( ) ) ;
2332+ assert ! ( Float :: copysign( nan, n) . is_sign_negative( ) ) ;
23302333 }
23312334
23322335 #[ cfg( any( feature = "std" , feature = "libm" ) ) ]
@@ -2341,8 +2344,7 @@ mod tests {
23412344 assert_eq ! ( n, n. copysign( n) ) ;
23422345 assert_eq ! ( n. neg( ) , n. copysign( p) ) ;
23432346
2344- // FIXME: is_sign... only works on NaN starting in Rust 1.20
2345- // assert!(nan.copysign(p).is_sign_positive());
2346- // assert!(nan.copysign(n).is_sign_negative());
2347+ assert ! ( nan. copysign( p) . is_sign_positive( ) ) ;
2348+ assert ! ( nan. copysign( n) . is_sign_negative( ) ) ;
23472349 }
23482350}
0 commit comments