hopr_lib

Function f64_approx_eq

Source
pub fn f64_approx_eq(a: f64, b: f64, epsilon: f64) -> bool
Expand description

Approximately compares two double-precision floats.

This function first tests if the two values relatively differ by at least epsilon. In case they are equal, the second test checks if they differ by at least two representable units of precision - meaning there can be only two other floats represented in between them. If both tests pass, the two values are considered (approximately) equal.