zu_util/
cmp.rs

1// Copyright (c) 2024 Xu Shaohua <shaohua@biofan.org>. All rights reserved.
2// Use of this source is governed by Lesser General Public License
3// that can be found in the LICENSE file.
4
5use float_cmp::ApproxEq;
6
7/// Compares two floating point values and returns true if they are considered equal,
8/// otherwise false.
9#[inline]
10#[must_use]
11pub fn fuzzy_compare(p1: f64, p2: f64) -> bool {
12    p1.approx_eq(p2, (0.0, 1))
13}