@@ -2308,26 +2308,45 @@ impl usize {
2308
2308
///
2309
2309
/// [`f32::classify()`]: ../../std/primitive.f32.html#method.classify
2310
2310
/// [`f64::classify()`]: ../../std/primitive.f64.html#method.classify
2311
+ ///
2312
+ /// # Examples
2313
+ ///
2314
+ /// ```
2315
+ /// use std::num::FpCategory;
2316
+ /// use std::f32;
2317
+ ///
2318
+ /// let num = 12.4_f32;
2319
+ /// let inf = f32::INFINITY;
2320
+ /// let zero = 0f32;
2321
+ /// let sub: f32 = 0.000000000000000000000000000000000000011754942;
2322
+ /// let nan = f32::NAN;
2323
+ ///
2324
+ /// assert_eq!(num.classify(), FpCategory::Normal);
2325
+ /// assert_eq!(inf.classify(), FpCategory::Infinite);
2326
+ /// assert_eq!(zero.classify(), FpCategory::Zero);
2327
+ /// assert_eq!(nan.classify(), FpCategory::Nan);
2328
+ /// assert_eq!(sub.classify(), FpCategory::Subnormal);
2329
+ /// ```
2311
2330
#[ derive( Copy , Clone , PartialEq , Debug ) ]
2312
2331
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2313
2332
pub enum FpCategory {
2314
- /// "Not a Number", often obtained by dividing by zero
2333
+ /// "Not a Number", often obtained by dividing by zero.
2315
2334
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2316
2335
Nan ,
2317
2336
2318
- /// Positive or negative infinity
2337
+ /// Positive or negative infinity.
2319
2338
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2320
2339
Infinite ,
2321
2340
2322
- /// Positive or negative zero
2341
+ /// Positive or negative zero.
2323
2342
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2324
2343
Zero ,
2325
2344
2326
- /// De-normalized floating point representation (less precise than `Normal`)
2345
+ /// De-normalized floating point representation (less precise than `Normal`).
2327
2346
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2328
2347
Subnormal ,
2329
2348
2330
- /// A regular floating point number
2349
+ /// A regular floating point number.
2331
2350
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2332
2351
Normal ,
2333
2352
}
0 commit comments