Resources Numerical accuracy

Equality comparisons

Where the code asks whether two decimal numbers are exactly equal. A floating-point result can differ from another in the last digit after a few transformations, so a mesh run through several of them can change the length of an edge, or miss a match. Compare with < or > where a range is meant, and with a documented epsilon where equality is.

  • 316 comparisons to look at
  • 149 files
  • 175 likely to matter (against a decimal, or two computed values)
  • Scanned

Equality comparisons

These are places worth checking, not confirmed bugs. The scan reads how the code is written, not what it is meant to do, so some entries are fine as they are: a test against exactly 0 is often a deliberate guard against dividing by zero. It skips text, counts and indexes, and any comparison it cannot be sure involves decimal numbers, so there are likely more in the code than are listed here.

  • Against 0 tetmesh.js:574 in stuffOnce PartCraft
    if (c.t === 0) continue;

    === in c.t === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Tetrahedral mesh of a part.

  • Against 0 assets/js/app-devices.js:214 in classifyWheel Shared shell, every app
    const step = dx === 0 && (legacy || (Number.isInteger(dy) && Math.abs(dy) >= 50));

    === in dx === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Not in the register.

  • Against 0 assets/js/app-devices.js:216 in classifyWheel Shared shell, every app
    if (dy === 0 && Number.isInteger(dx) && Math.abs(dx) >= 50 && !(mem.until > t)) return 'tilt';

    === in dy === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Not in the register.

  • Against 0 assets/js/app-panels.js:1336 in features Shared shell, every app
    if (q.x != null && q.y != null && q.x !== 0) f += ',left=' + q.x + ',top=' + q.y;

    !== in q.x !== 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Not in the register.

  • Against 0 assets/js/calc.js:347 in evalTree Shared shell, every app
    case '/': if (b.v === 0) fail('domain', 'Division by zero.', 'Check the divisor.'); return { v: a.v / b.v, d: ddiv(a.d, b.d) };

    === in b.v === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Calc sheets, Calc sheet units, functions and driven parameters.

  • Against 0 match.js:170 in nccPeaks TakeoffCraft
    if (u > v || (u === v && (dy < 0 || (dy === 0 && dx < 0)))) { best = false; break; }

    === in dy === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Automatic count by symbol matching.