Classify

Trait Classify 

Source
pub trait Classify {
    // Required method
    fn classify(&self) -> FpCategory;
}
Expand description

Trait for classifying floating-point values into categories.

This trait provides functionality to determine the category of a floating-point number according to the IEEE 754 standard (normal, subnormal, zero, infinite, or NaN).

§Examples

use num_valid::functions::Classify;
use std::num::FpCategory;

let normal = 42.0f64;
assert_eq!(Classify::classify(&normal), FpCategory::Normal);

let infinity = f64::INFINITY;
assert_eq!(Classify::classify(&infinity), FpCategory::Infinite);

let zero = 0.0f64;
assert_eq!(Classify::classify(&zero), FpCategory::Zero);

Required Methods§

Source

fn classify(&self) -> FpCategory

Returns the floating point category of the number. If only one property is going to be tested, it is generally faster to use the specific predicate instead.

use num_valid::functions::Classify;
use std::num::FpCategory;

let num = 12.4_f64;
let inf = f64::INFINITY;

assert_eq!(Classify::classify(&num), FpCategory::Normal);
assert_eq!(Classify::classify(&inf), FpCategory::Infinite);

Implementations on Foreign Types§

Source§

impl Classify for f64

Source§

fn classify(&self) -> FpCategory

Returns the floating point category of the number. If only one property is going to be tested, it is generally faster to use the specific predicate instead.

use num_valid::functions::Classify;
use std::num::FpCategory;

let num = 12.4_f64;
let inf = f64::INFINITY;

assert_eq!(Classify::classify(&num), FpCategory::Normal);
assert_eq!(Classify::classify(&inf), FpCategory::Infinite);

Implementors§