Skip to main content

is_close

Function is_close 

Source
pub fn is_close(a: FloatType, b: FloatType, abs_tol: FloatType) -> bool
Expand description

Python’s math.isclose(a, b, abs_tol=abs_tol), with its relative tolerance of one in a billion.

use music21::common::numbertools::is_close;

assert!(is_close(0.1 + 0.2, 0.3, 0.0));
assert!(!is_close(1.0, 1.1, 0.01));