@@ -2308,26 +2308,45 @@ impl usize {
23082308///
23092309/// [`f32::classify()`]: ../../std/primitive.f32.html#method.classify
23102310/// [`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+ /// ```
23112330#[ derive( Copy , Clone , PartialEq , Debug ) ]
23122331#[ stable( feature = "rust1" , since = "1.0.0" ) ]
23132332pub enum FpCategory {
2314- /// "Not a Number", often obtained by dividing by zero
2333+ /// "Not a Number", often obtained by dividing by zero.
23152334 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
23162335 Nan ,
23172336
2318- /// Positive or negative infinity
2337+ /// Positive or negative infinity.
23192338 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
23202339 Infinite ,
23212340
2322- /// Positive or negative zero
2341+ /// Positive or negative zero.
23232342 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
23242343 Zero ,
23252344
2326- /// De-normalized floating point representation (less precise than `Normal`)
2345+ /// De-normalized floating point representation (less precise than `Normal`).
23272346 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
23282347 Subnormal ,
23292348
2330- /// A regular floating point number
2349+ /// A regular floating point number.
23312350 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
23322351 Normal ,
23332352}
0 commit comments