mirror of
https://github.com/Tonejs/Tone.js
synced 2024-12-29 04:53:10 +00:00
33 lines
662 B
TypeScript
33 lines
662 B
TypeScript
/**
|
|
* The threshold for correctness for operators. Less than one sample even
|
|
* at very high sampling rates (e.g. `1e-6 < 1 / 192000`).
|
|
*/
|
|
const EPSILON = 1e-6;
|
|
|
|
/**
|
|
* Test if A is greater than B
|
|
*/
|
|
export function GT(a: number, b: number): boolean {
|
|
return a > b + EPSILON;
|
|
}
|
|
|
|
/**
|
|
* Test if A is greater than or equal to B
|
|
*/
|
|
export function GTE(a: number, b: number): boolean {
|
|
return GT(a, b) || EQ(a, b);
|
|
}
|
|
|
|
/**
|
|
* Test if A is less than B
|
|
*/
|
|
export function LT(a: number, b: number): boolean {
|
|
return a + EPSILON < b;
|
|
}
|
|
|
|
/**
|
|
* Test if A is less than B
|
|
*/
|
|
export function EQ(a: number, b: number): boolean {
|
|
return Math.abs(a - b) < EPSILON;
|
|
}
|