@@ -303,21 +303,15 @@ impl f64 {
303303 #[ inline]
304304 pub fn signum ( self ) -> f64 { num:: Float :: signum ( self ) }
305305
306- /// Returns `true` if `self`'s sign bit is positive, including
307- /// `+0.0` and `INFINITY` .
306+ /// Returns `true` if and only if `self` has a positive sign , including `+0.0`, `NaN`s with
307+ /// positive sign bit and positive infinity .
308308 ///
309309 /// ```
310- /// use std::f64;
311- ///
312- /// let nan: f64 = f64::NAN;
313- ///
314310 /// let f = 7.0_f64;
315311 /// let g = -7.0_f64;
316312 ///
317313 /// assert!(f.is_sign_positive());
318314 /// assert!(!g.is_sign_positive());
319- /// // Requires both tests to determine if is `NaN`
320- /// assert!(!nan.is_sign_positive() && !nan.is_sign_negative());
321315 /// ```
322316 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
323317 #[ inline]
@@ -328,21 +322,15 @@ impl f64 {
328322 #[ inline]
329323 pub fn is_positive ( self ) -> bool { num:: Float :: is_sign_positive ( self ) }
330324
331- /// Returns `true` if `self`'s sign is negative, including `-0.0`
332- /// and `NEG_INFINITY` .
325+ /// Returns `true` if and only if `self` has a negative sign , including `-0.0`, `NaN`s with
326+ /// negative sign bit and negative infinity .
333327 ///
334328 /// ```
335- /// use std::f64;
336- ///
337- /// let nan = f64::NAN;
338- ///
339329 /// let f = 7.0_f64;
340330 /// let g = -7.0_f64;
341331 ///
342332 /// assert!(!f.is_sign_negative());
343333 /// assert!(g.is_sign_negative());
344- /// // Requires both tests to determine if is `NaN`.
345- /// assert!(!nan.is_sign_positive() && !nan.is_sign_negative());
346334 /// ```
347335 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
348336 #[ inline]
@@ -1103,7 +1091,7 @@ mod tests {
11031091 assert ! ( !nan. is_infinite( ) ) ;
11041092 assert ! ( !nan. is_finite( ) ) ;
11051093 assert ! ( !nan. is_normal( ) ) ;
1106- assert ! ( ! nan. is_sign_positive( ) ) ;
1094+ assert ! ( nan. is_sign_positive( ) ) ;
11071095 assert ! ( !nan. is_sign_negative( ) ) ;
11081096 assert_eq ! ( Fp :: Nan , nan. classify( ) ) ;
11091097 }
@@ -1346,7 +1334,8 @@ mod tests {
13461334 assert ! ( !( -1f64 ) . is_sign_positive( ) ) ;
13471335 assert ! ( !NEG_INFINITY . is_sign_positive( ) ) ;
13481336 assert ! ( !( 1f64 /NEG_INFINITY ) . is_sign_positive( ) ) ;
1349- assert ! ( !NAN . is_sign_positive( ) ) ;
1337+ assert ! ( NAN . is_sign_positive( ) ) ;
1338+ assert ! ( !( -NAN ) . is_sign_positive( ) ) ;
13501339 }
13511340
13521341 #[ test]
@@ -1359,6 +1348,7 @@ mod tests {
13591348 assert ! ( NEG_INFINITY . is_sign_negative( ) ) ;
13601349 assert ! ( ( 1f64 /NEG_INFINITY ) . is_sign_negative( ) ) ;
13611350 assert ! ( !NAN . is_sign_negative( ) ) ;
1351+ assert ! ( ( -NAN ) . is_sign_negative( ) ) ;
13621352 }
13631353
13641354 #[ test]
0 commit comments