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.
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 1 supply.js:99 in readSupply TakeoffCraft
if (!json || typeof json !== 'object' || json.v !== 1) return null;!== in
json.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Supplier stock and lead-time check. -
Against 0 ifc/geo-tri.js:133 in clip BimCraft, TakeoffCraft, CivilCraft, DetailCraft
if (cross(a, e, c) === 0 && !between(a, e, c)) { remove(e); count--; if (e === stop) stop = c; e = c; if (count < 3) return; continue; }=== in
cross(a, e, c) === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Polygon triangulation by ear clipping. -
Against 0 ifc/geo-tri.js:145 in clip BimCraft, TakeoffCraft, CivilCraft, DetailCraft
while (p.next !== e) { if (cross(e, p, p.next) !== 0) out.push(e.i, p.i, p.next.i); p = p.next; }!== in
cross(e, p, p.next) !== 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Polygon triangulation by ear clipping. -
Against 0 lencalc.js:130 in term CadCraft, ModelCraft, MarkupCraft, TakeoffCraft, CivilCraft, DetailCraft
if (o.t === '/' && b.v === 0) throw new CalcError('divide', o.pos);=== 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: Arithmetic on typed lengths. -
Against 0 m3d/earcut.js:51 in filterPoints CadCraft, TakeoffCraft
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {=== in
area(p.prev, p, p.next) === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Triangulation of faces with holes. -
Against 0 usd/earcut.js:52 in filterPoints CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {=== in
area(p.prev, p, p.next) === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Polygon triangulation (ear clipping). -
Against 0 usd/usda-read.js:476 in component CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
if (c.k === 'num') { this.i++; return c.v !== 0; }!== in
c.v !== 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Floats read from USD files. -
Against 0 wheel-pad.js:20 in isSwipe CadCraft, BimCraft, MarkupCraft, TakeoffCraft, CivilCraft
const step = dx === 0 && ((Number.isFinite(e.wheelDeltaY) && e.wheelDeltaY !== 0 && e.wheelDeltaY % 120 === 0) || (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 wheel-pad.js:22 in isSwipe CadCraft, BimCraft, MarkupCraft, TakeoffCraft, CivilCraft
if (dx !== 0 || !Number.isInteger(dy) || Math.abs(dy) < 50) { this.until = t + 400; return true; }!== 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 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.