Crate tolerance

source ·
Expand description

Tolerance

Math representation of the physically needed permissible deviation of measures in Rust avoiding floating point inaccuracy. Allows to calculate with tolerance ranges in a consistent way.

Based on Myth-types with a accuracy of 1/10th my-meter (= 0.1μ) as the name suggests.

Example

use tolerance::T128;

let width1 = T128::new(100.0, 0.05, -0.2);
let width2 = T128::with_sym(50.0, 0.05);

// Adding two `T128`s is straightforward.
assert_eq!(width1 + width2, T128::new(150.0, 0.1, -0.25));

// `!` inverts the direction of tolerance to /subtract/ measures.
assert_eq!(!width1, T128::new(-100.0, 0.2, -0.05));

// Adding an inverted `T128` wides the tolerance.
assert_eq!(width1 + !width1, T128::new(0.0, 0.25, -0.25));

Modules

Structs