Skip to main content

approx_eq

Function approx_eq 

pub fn approx_eq(
    left: Real,
    right: Real,
    tolerance: f64,
) -> Result<bool, RealError>
Expand description

Compares two real values with an explicit non-negative tolerance.

§Errors

Returns RealError::NonFiniteTolerance when tolerance is not finite, and RealError::NegativeTolerance when tolerance < 0.0.

§Examples

use use_real::{Real, approx_eq};

let left = Real::try_new(1.0)?;
let right = Real::try_new(1.0 + 1.0e-10)?;

assert!(approx_eq(left, right, 1.0e-9)?);