All files / src/shared/lib/helpers math.ts

0% Statements 0/7
0% Branches 0/1
0% Functions 0/1
0% Lines 0/6

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;
};