logo
pub trait FloatEq {
    fn float_eq(&self, other: &Self) -> bool;
}
Expand description

Equivalence relation for floating-point primitives.

FloatEq agrees with the total ordering provided by FloatOrd. See the module documentation for more. Importantly, given the set of NaN representations $N$, FloatEq expresses:

$$ \begin{aligned} a=b&\mid a\in{N},~b\in{N}\cr[1em] n\ne x&\mid n\in{N},~x\notin{N} \end{aligned} $$

Examples

Comparing NaNs using primitive floating-point types:

use decorum::cmp::FloatEq;
use decorum::Infinite;

let x = 0.0f64 / 0.0; // `NaN`.
let y = f64::INFINITY - f64::INFINITY; // `NaN`.

assert!(x.float_eq(&y));

Required Methods

Implementations on Foreign Types

Implementors