FpChecks

Trait FpChecks 

Source
pub trait FpChecks {
    // Required methods
    fn is_finite(&self) -> bool;
    fn is_infinite(&self) -> bool;
    fn is_nan(&self) -> bool;
    fn is_normal(&self) -> bool;
}
Expand description

Provides a set of fundamental floating-point classification checks.

This trait defines common methods to determine the characteristics of a numerical value, such as whether it is finite, infinite, NaN (Not a Number), or normal. It is implemented for standard floating-point types (f64), complex numbers (num::Complex<f64>), and their arbitrary-precision counterparts from the rug library (via RealRugStrictFinite<P> and ComplexRugStrictFinite<P> which internally use rug::Float and rug::Complex) when the “rug” feature is enabled.

FpChecks is often used as a supertrait for more general numerical traits like FpScalar, ensuring that types representing floating-point scalars can be queried for these basic properties. This is essential for validation policies and writing robust numerical algorithms.

Note that this trait focuses on these specific classifications. For more detailed categorization (like distinguishing subnormals or zero explicitly through this trait), types may provide other methods (e.g., classify() for f64 and rug::Float, or is_zero() from FpScalar).

Required Methods§

Source

fn is_finite(&self) -> bool

Returns true if self is finite (i.e., not infinite and not NaN).

For complex numbers, this typically means both the real and imaginary parts are finite.

Source

fn is_infinite(&self) -> bool

Returns true if self is positive infinity or negative infinity.

For complex numbers, this typically means at least one part is infinite, and no part is NaN.

Source

fn is_nan(&self) -> bool

Returns true if self is NaN (Not a Number).

For complex numbers, this typically means at least one part is NaN.

Source

fn is_normal(&self) -> bool

Returns true if self is a normal number.

A normal number is a finite, non-zero number that is not subnormal. For complex numbers, this typically means both real and imaginary parts are normal numbers (and thus individually finite, non-zero, and not subnormal).

Implementations on Foreign Types§

Source§

impl FpChecks for f64

Source§

fn is_finite(&self) -> bool

Source§

fn is_infinite(&self) -> bool

Source§

fn is_nan(&self) -> bool

Source§

fn is_normal(&self) -> bool

Source§

impl FpChecks for Complex<f64>

Source§

fn is_finite(&self) -> bool

Source§

fn is_infinite(&self) -> bool

Source§

fn is_nan(&self) -> bool

Source§

fn is_normal(&self) -> bool

Source§

impl FpChecks for Complex

Source§

fn is_finite(&self) -> bool

Returns true if the real and imaginary parts of self are neither infinite nor NaN.

Source§

fn is_infinite(&self) -> bool

Returns true if the real or the imaginary part of self are positive infinity or negative infinity.

Source§

fn is_nan(&self) -> bool

Returns true if the real or the imaginary part of self are NaN.

Source§

fn is_normal(&self) -> bool

Returns true if the real and the imaginary part of self are normal (i.e. neither zero, infinite, subnormal, or NaN).

Source§

impl FpChecks for Float

Source§

fn is_finite(&self) -> bool

Source§

fn is_infinite(&self) -> bool

Source§

fn is_nan(&self) -> bool

Source§

fn is_normal(&self) -> bool

Implementors§