@@ -505,8 +505,7 @@ pub trait FloatCore: Num + NumCast + Neg<Output = Self> + PartialOrd + Copy {
505
505
}
506
506
507
507
/// 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()`.
510
509
///
511
510
/// # Examples
512
511
///
@@ -524,6 +523,7 @@ pub trait FloatCore: Num + NumCast + Neg<Output = Self> + PartialOrd + Copy {
524
523
/// check(-0.0f64, false);
525
524
/// check(f64::NEG_INFINITY, false);
526
525
/// check(f64::MIN_POSITIVE, true);
526
+ /// check(f64::NAN, true);
527
527
/// check(-f64::NAN, false);
528
528
/// ```
529
529
#[ inline]
@@ -532,8 +532,7 @@ pub trait FloatCore: Num + NumCast + Neg<Output = Self> + PartialOrd + Copy {
532
532
}
533
533
534
534
/// 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()`.
537
536
///
538
537
/// # Examples
539
538
///
@@ -552,6 +551,7 @@ pub trait FloatCore: Num + NumCast + Neg<Output = Self> + PartialOrd + Copy {
552
551
/// check(f64::NEG_INFINITY, true);
553
552
/// check(f64::MIN_POSITIVE, false);
554
553
/// check(f64::NAN, false);
554
+ /// check(-f64::NAN, true);
555
555
/// ```
556
556
#[ inline]
557
557
fn is_sign_negative ( self ) -> bool {
@@ -1263,38 +1263,42 @@ pub trait Float: Num + Copy + NumCast + PartialOrd + Neg<Output = Self> {
1263
1263
fn signum ( self ) -> Self ;
1264
1264
1265
1265
/// 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()`.
1267
1267
///
1268
1268
/// ```
1269
1269
/// use num_traits::Float;
1270
1270
/// use std::f64;
1271
1271
///
1272
+ /// let nan: f64 = f64::NAN;
1272
1273
/// let neg_nan: f64 = -f64::NAN;
1273
1274
///
1274
1275
/// let f = 7.0;
1275
1276
/// let g = -7.0;
1276
1277
///
1277
1278
/// assert!(f.is_sign_positive());
1278
1279
/// assert!(!g.is_sign_positive());
1280
+ /// assert!(nan.is_sign_positive());
1279
1281
/// assert!(!neg_nan.is_sign_positive());
1280
1282
/// ```
1281
1283
fn is_sign_positive ( self ) -> bool ;
1282
1284
1283
1285
/// 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()`.
1285
1287
///
1286
1288
/// ```
1287
1289
/// use num_traits::Float;
1288
1290
/// use std::f64;
1289
1291
///
1290
1292
/// let nan: f64 = f64::NAN;
1293
+ /// let neg_nan: f64 = -f64::NAN;
1291
1294
///
1292
1295
/// let f = 7.0;
1293
1296
/// let g = -7.0;
1294
1297
///
1295
1298
/// assert!(!f.is_sign_negative());
1296
1299
/// assert!(g.is_sign_negative());
1297
1300
/// assert!(!nan.is_sign_negative());
1301
+ /// assert!(neg_nan.is_sign_negative());
1298
1302
/// ```
1299
1303
fn is_sign_negative ( self ) -> bool ;
1300
1304
@@ -2324,9 +2328,8 @@ mod tests {
2324
2328
assert_eq ! ( n, Float :: copysign( n, n) ) ;
2325
2329
assert_eq ! ( n. neg( ) , Float :: copysign( n, p) ) ;
2326
2330
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( ) ) ;
2330
2333
}
2331
2334
2332
2335
#[ cfg( any( feature = "std" , feature = "libm" ) ) ]
@@ -2341,8 +2344,7 @@ mod tests {
2341
2344
assert_eq ! ( n, n. copysign( n) ) ;
2342
2345
assert_eq ! ( n. neg( ) , n. copysign( p) ) ;
2343
2346
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( ) ) ;
2347
2349
}
2348
2350
}
0 commit comments