Trait rsvg::float_eq_cairo::ApproxEqCairo
source · pub trait ApproxEqCairo: ApproxEq {
fn approx_eq_cairo(self, other: Self) -> bool;
}
Expand description
Checks whether two floating-point numbers are approximately equal, considering Cairo’s limitations on numeric representation.
Cairo uses fixed-point numbers internally. We implement this
trait for f64
, so that two numbers can be considered “close
enough to equal” if their absolute difference is smaller than the
smallest fixed-point fraction that Cairo can represent.
Note that this trait is reliable even if the given numbers are outside of the range that Cairo’s fixed-point numbers can represent. In that case, we check for the absolute difference, and finally allow a difference of 1 unit-in-the-last-place (ULP) for very large f64 values.