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 libitem.js:1715 in emit CadCraft, BimCraft
    if (c4 && (c4.x !== c3.x || c4.y !== c3.y || (c4.z || 0) !== (c3.z || 0))) faces.push(q[0], q[2], q[3]);

    !== in (c4.z || 0) !== (c3.z || 0). Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Library item geometry from blocks, meshes and tables, Lengths and units for Library items.

  • Two computed values unit-table.js:126 in convert CadCraft, BimCraft, ModelCraft, MarkupCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (a === b || a.factor === b.factor) return v;

    === in a.factor === b.factor. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Unit conversion, Unit table: reading and writing values.

  • Two computed values usd/earcut.js:162 in findHoleBridge CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {

    !== in p.next.y !== p.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation (ear clipping).

  • Two computed values usd/earcut.js:180 in findHoleBridge CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (locallyInside(p, hole) && (tan < tanMin || (tan === tanMin && (p.x > m.x || (p.x === m.x && sectorContainsSector(m, p)))))) {

    === in p.x === m.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation (ear clipping).

  • Two computed values usd/earcut.js:195 in getLeftmost CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (p.x < leftmost.x || (p.x === leftmost.x && p.y < leftmost.y)) leftmost = p;

    === in p.x === leftmost.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation (ear clipping).

  • Two computed values usd/earcut.js:218 in equals CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    const equals = (p1, p2) => p1.x === p2.x && p1.y === p2.y;

    === in p1.x === p2.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation (ear clipping).

  • Two computed values usd/earcut.js:218 in equals CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    const equals = (p1, p2) => p1.x === p2.x && p1.y === p2.y;

    === in p1.y === p2.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation (ear clipping).

  • Two computed values usd/earcut.js:248 in middleInside CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y && (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x)) inside = !inside;

    !== in p.next.y !== p.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Polygon triangulation (ear clipping).

  • Two computed values usd/geom.js:92 in valueAt CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (!a || !b || a.t !== b.t || typeof a.v === 'string' || a.t.startsWith('quat') || a.t.includes('token') || a.t === 'bool') return a;

    !== in a.t !== b.t. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: USD transforms and placement, USD mesh coordinates in saved and exported files.

  • Against a whole number people-sim.js:142 in field BimCraft
    if (Math.abs(di) + Math.abs(dj) === 2 && (!free[cj * nx + i] || !free[j * nx + ci])) continue;   // no cutting a corner

    === in Math.abs(di) + Math.abs(dj) === 2. Check that the value is exact by construction; if not, compare within an epsilon. Reviewed: People movement and travel distance.

  • Against a whole number people-sim.js:143 in field BimCraft
    if (Math.abs(di) === 2 && (!free[cj * nx + ci + di / 2] || !free[j * nx + ci + di / 2])) continue;   // knight move: both middle cells free

    === in Math.abs(di) === 2. Check that the value is exact by construction; if not, compare within an epsilon. Reviewed: People movement and travel distance.

  • Against a whole number people-sim.js:144 in field BimCraft
    if (Math.abs(dj) === 2 && (!free[(cj + dj / 2) * nx + ci] || !free[(cj + dj / 2) * nx + i])) continue;

    === in Math.abs(dj) === 2. Check that the value is exact by construction; if not, compare within an epsilon. Reviewed: People movement and travel distance.

  • Against 1 addons/plant/lib/core.js:12 in lookupFrom BimCraft
    if (s && typeof s === 'object') s = (vars.n !== undefined && s['=' + vars.n]) || (Number(vars.n) === 1 && s.one) || s.other || key;

    === in Number(vars.n) === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 addons/sprinkler/lib/core.js:12 in lookupFrom BimCraft
    if (s && typeof s === 'object') s = (vars.n !== undefined && s['=' + vars.n]) || (Number(vars.n) === 1 && s.one) || s.other || key;

    === in Number(vars.n) === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 render/pt-ggx.js:55 in modulatedEta BimCraft, ModelCraft
    if (weight === 1) return eta;

    === in weight === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Path tracer kernels.

  • Against 1 site-context.js:59 in cleanContext BimCraft, ModelCraft, CivilCraft
    if (!o || typeof o !== 'object' || o.format !== FORMAT || o.v !== 1) return null;

    !== in o.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Site surroundings in local meters.

  • Against 1 xr/xr-core.js:179 in cleanPeer BimCraft, ModelCraft
    if (!x || typeof x !== 'object' || x.v !== 1 || !isPose(x.h)) return null;

    !== in x.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Headset review: measuring, section cuts and issue cameras, AR on site: lining the model up with the building.

  • Against 1 addons/cabinetcraft/lib/core.js:17 in lookupFrom CadCraft, BimCraft, ModelCraft, PartCraft
    if (s && typeof s === 'object') s = (vars.n !== undefined && s['=' + vars.n]) || (Number(vars.n) === 1 && s.one) || s.other || key;

    === in Number(vars.n) === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 addons/trusscraft/lib/core.js:12 in lookupFrom CadCraft, BimCraft, ModelCraft, PartCraft
    if (s && typeof s === 'object') s = (vars.n !== undefined && s['=' + vars.n]) || (Number(vars.n) === 1 && s.one) || s.other || key;

    === in Number(vars.n) === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 areaclip.js:75 in cleanAreaClip CadCraft, BimCraft, MarkupCraft, DetailCraft
    if (!d || typeof d !== 'object' || d.format !== AREA_FORMAT || d.v !== 1) return null;

    !== in d.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Size of a copied area.

  • Against 1 dwg/messages.js:188 in msg CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (typeof s === 'object') s = s['=' + fills.n] ?? (Number(fills.n) === 1 ? s.one : s.other) ?? s.other;

    === in Number(fills.n) === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 dwg/objects-write.js:658 in insertScale CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    if (sx === 1 && sy === 1 && sz === 1) w.BB(3);

    === in sx === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: DWG object values written and read.

  • Against 1 dwg/objects-write.js:658 in insertScale CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    if (sx === 1 && sy === 1 && sz === 1) w.BB(3);

    === in sy === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: DWG object values written and read.

  • Against 1 dwg/objects-write.js:658 in insertScale CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    if (sx === 1 && sy === 1 && sz === 1) w.BB(3);

    === in sz === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: DWG object values written and read.

  • Against 1 dwg/objects-write.js:660 in insertScale CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    else if (sx === 1) { w.BB(1); w.DD(sy, 1); w.DD(sz, 1); }

    === in sx === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: DWG object values written and read.

  • Against 1 dwg/objects-write.js:774 CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    const weights = ctrl.some((p) => p.w !== undefined && p.w !== 1) || (r.weights || []).some((x) => x !== 1);

    !== in p.w !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: DWG object values written and read.

  • Against 1 dwg/objects-write.js:818 CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    const rational = ctl.some((p) => p.w !== undefined && p.w !== 1);

    !== in p.w !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: DWG object values written and read.

  • Against 1 dxf-model.js:58 in msg CadCraft, BimCraft, TakeoffCraft, CivilCraft
    if (typeof s === 'object') s = s['=' + fills.n] ?? (Number(fills.n) === 1 ? s.one : s.other) ?? s.other;

    === in Number(fills.n) === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: DXF reading into the shared drawing model.

  • Against 1 libitem.js:233 in msg CadCraft, BimCraft
    if (typeof s === 'object') s = s['=' + fills.n] ?? (Number(fills.n) === 1 ? s.one : s.other) ?? s.other;

    === in Number(fills.n) === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Library item geometry from blocks, meshes and tables, Lengths and units for Library items.

  • Against 1 libitem.js:1465 in drawingUnits CadCraft, BimCraft
    const metric = Number(db.header?.MEASUREMENT) === 1;

    === in Number(db.header?.MEASUREMENT) === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Library item geometry from blocks, meshes and tables, Lengths and units for Library items.

  • Against 1 live-crypto.js:329 in verifyAssertion CadCraft, BimCraft, ModelCraft, MarkupCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (!sig || !claims || claims.v !== 1 || typeof claims.name !== 'string') return { ok: false, reason: 'format' };

    !== in claims.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 process/env/cheminfo.js:182 in groupsOf CadCraft, BimCraft
    if (arom) inc(a.h === 1 ? 'ring =CH-' : a.h === 0 ? 'ring =C<' : 'ring =CH-');

    === in a.h === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Molar mass and group-contribution estimates.

  • Against 1 process/env/cheminfo.js:184 in groupsOf CadCraft, BimCraft
    else if (dbl) { if (nb[i].some((x) => x.order === 2 && mol.atoms[x.o].el !== 'C')) missing.push('carbonyl or C=X carbon'); else if (inRing[i]) missing.push('ring alkene carbon'); else if (dbl === 1 &&

    === in a.h === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Molar mass and group-contribution estimates.

  • Against 1 process/env/cheminfo.js:185 in groupsOf CadCraft, BimCraft
    else if (inRing[i]) { if (a.h === 2) inc('ring CH2'); else if (a.h === 1) inc('ring CH'); else missing.push('ring quaternary carbon'); }

    === in a.h === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Molar mass and group-contribution estimates.

  • Against 1 process/env/cheminfo.js:188 in groupsOf CadCraft, BimCraft
    if (a.h === 1 && nb[i].length === 1 && !mol.atoms[nb[i][0].o].aromatic) inc('-OH (alcohol)');

    === in a.h === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Molar mass and group-contribution estimates.

  • Against 1 process/env/molsketch.js:85 in symbol CadCraft, BimCraft
    return '[' + el + (a.h ? (a.h === 1 ? 'H' : 'H' + a.h) : '') + (q ? (q > 0 ? '+' + (q > 1 ? q : '') : '-' + (q < -1 ? -q : '')) : '') + ']';

    === in a.h === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 process/live.js:37 in readPacket CadCraft, BimCraft
    if (!raw || typeof raw !== 'object' || raw.format !== FORMAT || raw.v !== 1) return null;

    !== in raw.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 process/safety/hazoptimer.js:57 in restore CadCraft, BimCraft
    if (!s || s.v !== 1 || !Array.isArray(s.rows)) return false;

    !== in s.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Not in the register.

  • Against 1 usd/usda-write.js:40 in subLayersText CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    return asset(a) + (o && (o.offset !== 0 || o.scale !== 1) ? ' (' + layerOffsetText(o) + ')' : '');

    !== in o.scale !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Number text in USD files.

  • Against 1 usd/usda-write.js:47 in layerOffsetText CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (o.scale !== 1) parts.push('scale = ' + num(o.scale, 'f64'));

    !== in o.scale !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Number text in USD files.

  • Against 1 usd/usda-write.js:172 in listItemText CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    if (o && (o.offset !== 0 || o.scale !== 1)) parts.push(layerOffsetText(o));

    !== in o.scale !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Number text in USD files.

  • Against 0 assembly-preview.js:11 in assemblyDimensionLayout BimCraft
    const label=`${i+1}: ${format(l.t)}${l.t===0?' *':''}`,half=Math.min(450,label.length*4+8);

    === in l.t===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 assembly-schedule.js:51 in assemblySchedules BimCraft
    const designation=cavity?tr('asched.cavity.vent',{vent:l.ventilation}):membrane?(l.t===0?tr('asched.membrane.zero'):tr('asched.membrane.nominal')):tr('asched.material');

    === in l.t===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 framing.js:215 in panelSvg BimCraft, DetailCraft
    const rise = p.h, run = p.w, left = p.x === 0;

    === in p.x === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Framing panels and cut lists.

  • Against 0 framing.js:324 in placePanel BimCraft, DetailCraft
    const left = pc.x === 0, n = c + sz.face / 2;

    === in pc.x === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Framing panels and cut lists.

  • Against 0 framing.js:353 in panelPage BimCraft, DetailCraft
    const left = pc.x === 0;

    === in pc.x === 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Framing panels and cut lists.

  • 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 raster.js:118 in openGeoTiff BimCraft, CivilCraft
    const scale = Number.isFinite(meta.scale) && meta.scale !== 0 ? meta.scale : 1;

    !== in meta.scale !== 0. Usually fine as a guard against dividing by zero; check it is not meant to catch a near-zero value too. Reviewed: Elevation grids read from GeoTIFF and ASCII files.

  • Against 0 wall-assemblies-ui.js:51 in totals BimCraft
    preview.append(el('div',{style:`position:absolute;box-sizing:border-box;left:${span.start/10}%;width:${(span.end-span.start)/10}%;height:100%;background:${l.kind==='cavity'?'transparent':materialBackg

    === in l.t===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.