Struct float_cmp::F32Margin[][src]

#[repr(C)]
pub struct F32Margin { pub epsilon: f32, pub ulps: i32, }
Expand description

This type defines a margin within two f32 values might be considered equal, and is intended as the associated type for the ApproxEq trait.

Two tests are used to determine approximate equality.

The first test considers two values approximately equal if they differ by <= epsilon. This will only succeed for very small numbers. Note that it may succeed even if the parameters are of differing signs, straddling zero.

The second test considers how many ULPs (units of least precision, units in the last place, which is the integer number of floating-point representations that the parameters are separated by) different the parameters are and considers them approximately equal if this is <= ulps. For large floating-point numbers, an ULP can be a rather large gap, but this kind of comparison is necessary because floating-point operations must round to the nearest representable value and so larger floating-point values accumulate larger errors.

Fields

epsilon: f32ulps: i32

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.