Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | export const areRelativelyEqual = ( a: number, b: number, tolerance: number ): boolean => { Iif (a === b) { return true; // Handles the case where both are exactly the same, including 0 } const diff = Math.abs(a - b); const scale = Math.max(Math.abs(a), Math.abs(b)); // Check if the difference is within the tolerance percentage of the larger magnitude return diff <= scale * tolerance; }; |