approx_equal

Function approx_equal 

Source
pub fn approx_equal<T, U>(a: T, b: U, epsilon: Option<f64>) -> bool
where T: NumCast + Copy + Debug, U: NumCast + Copy + Debug,
Expand description

Check if two numeric values are approximately equal within a specified epsilon.

This function works with any floating point or integer type that can be converted to a float. For integer types, it converts them to f64 for comparison.

§Arguments

  • a - First value to compare
  • b - Second value to compare
  • epsilon - Tolerance for equality comparison (defaults to 1e-10 if not specified)

§Returns

  • bool - True if the values are approximately equal, false otherwise