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.

  • Two computed values timeline.js:305 in refresh ModelCraft
    picked = picked.filter((p) => keysOf(p.track).some((k) => k.t === p.t));

    === in k.t === p.t. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Not in the register.

  • Two computed values timeline.js:337 in keyOf ModelCraft
    return ks && ks.find((x) => x.t === p.t);

    === in x.t === p.t. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Not in the register.

  • Two computed values tools.js:1060 in down ModelCraft
    const inSel = this.h.sel.some((x) => x.t === s.t && x.id === s.id);

    === in x.t === s.t. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Not in the register.