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 a decimal addons/electrical/main.js:299 in activate CadCraft
    const u = yes(await c.keyword(t('ask.symlib.units'), { options: [opt('M', t('opt.mm')), opt('I', t('opt.inches'))], default: per === 25.4 || per === 304.8 ? 'I' : 'M' }));

    === in per === 25.4. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Schematic wires, pins and connections.

  • Against a decimal addons/electrical/main.js:299 in activate CadCraft
    const u = yes(await c.keyword(t('ask.symlib.units'), { options: [opt('M', t('opt.mm')), opt('I', t('opt.inches'))], default: per === 25.4 || per === 304.8 ? 'I' : 'M' }));

    === in per === 304.8. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Schematic wires, pins and connections.

  • Against a decimal addons/electrical/main.js:301 in activate CadCraft
    const scale = u === 'I' ? 25.4 : per >= 10 && per !== 25.4 && per !== 304.8 ? per : 1;

    !== in per !== 25.4. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Schematic wires, pins and connections.

  • Against a decimal addons/electrical/main.js:301 in activate CadCraft
    const scale = u === 'I' ? 25.4 : per >= 10 && per !== 25.4 && per !== 304.8 ? per : 1;

    !== in per !== 304.8. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Schematic wires, pins and connections.

  • Against a decimal m3d/tools.js:1542 in computeGrips CadCraft
    if (f.every((x) => x === 0.5)) continue;

    === in x === 0.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: 3D drawing and editing tools.

  • Against a decimal m3d/tools.js:1543 in computeGrips CadCraft
    const mask = f.map((x, a) => x !== 0.5 && live[a]);

    !== in x !== 0.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: 3D drawing and editing tools.

  • Against a decimal process/env/cheminfo.js:77 in parse CadCraft, BimCraft
    const sum = atoms.map(() => 0); for (const b of bonds) { sum[b.a] += b.order === 1.5 ? 1 : b.order; sum[b.b] += b.order === 1.5 ? 1 : b.order; }

    === in b.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Molar mass and group-contribution estimates.

  • Against a decimal process/env/cheminfo.js:77 in parse CadCraft, BimCraft
    const sum = atoms.map(() => 0); for (const b of bonds) { sum[b.a] += b.order === 1.5 ? 1 : b.order; sum[b.b] += b.order === 1.5 ? 1 : b.order; }

    === in b.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Molar mass and group-contribution estimates.

  • Against a decimal process/env/cheminfo.js:126 in toMol CadCraft, BimCraft
    mol.bonds.forEach((b) => L.push(pad(b.a + 1, 3) + pad(b.b + 1, 3) + pad(b.order === 1.5 ? 4 : b.order, 3) + '  0'));

    === in b.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Molar mass and group-contribution estimates.

  • Against a decimal process/env/cheminfo.js:136 in fromMol CadCraft, BimCraft
    const sum = atoms.map(() => 0); for (const b of bonds) { const o = b.order === 1.5 ? 1 : b.order; sum[b.a] += o; sum[b.b] += o; }

    === in b.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Molar mass and group-contribution estimates.

  • Against a decimal process/env/cheminfo.js:148 in toSvg CadCraft, BimCraft
    out += b.order === 2 || b.order === 1.5 ? ln(nx, ny) + ln(-nx, -ny) : b.order === 3 ? ln(0, 0) + ln(2 * nx, 2 * ny) + ln(-2 * nx, -2 * ny) : ln(0, 0);

    === in b.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Molar mass and group-contribution estimates.

  • Against a decimal process/env/cheminfo.js:179 in groupsOf CadCraft, BimCraft
    const dbl = nb[i].filter((x) => x.order === 2).length, trp = nb[i].filter((x) => x.order === 3).length, arom = nb[i].some((x) => x.order === 1.5);

    === in x.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Molar mass and group-contribution estimates.

  • Against a decimal process/env/dispersion.js:100 in screen CadCraft, BimCraft
    const notes = ['Stability-class screening on flat ground, one source, no buildings. Ta ' + Ta + ' K' + (Ta === 293.15 ? ' (assumed: give the real ambient temperature)' : '') + '.',

    === in Ta === 293.15. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Stack plume rise and air dispersion screening.

  • Against a decimal process/env/molsketch.js:106 in fromMolecule CadCraft, BimCraft
    for (const b of mol.bonds) s.bonds.push({ a: b.a, b: b.b, order: b.order === 1.5 ? 1 : b.order });

    === in b.order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Not in the register.

  • Against a decimal process/env/molsketch.js:114 in kekulise CadCraft, BimCraft
    const arom = mol.bonds.map((b, k) => ({ k, a: b.a, b: b.b })).filter((e) => mol.bonds[e.k].order === 1.5 && need[e.a] && need[e.b]);

    === in mol.bonds[e.k].order === 1.5. Compare within a documented epsilon, or test with < or > if a range is meant. Not in the register.

  • Against a decimal process/equip/vessel.js:113 in flatHead CadCraft, BimCraft
    return { t, tMin: t + ca, C, notes: C === 0.33 ? ['C = 0.33 is the plain-plate value; the attachment detail of Figure UG-34 sets the real C (0.17 to 0.33 and others): give it'] : [], source: 'ASME VII

    === in C === 0.33. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Pressure vessel thickness and support formulas.

  • Against a decimal usd/util.js:60 in floatToHalf CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft, DetailCraft, PartCraft
    return sign | (rest > 0.5 || (rest === 0.5 && (r & 1)) ? r + 1 : r);

    === in rest === 0.5. Compare within a documented epsilon, or test with < or > if a range is meant. Reviewed: Half floats in USD.

  • Two computed values addons/cabinet/lib/cutlist/cutlist.js:86 in sameKind CadCraft
    const sameKind = (a, b) => a.material === b.material && a.thickness === b.thickness && a.length === b.length && a.width === b.width &&

    === in a.thickness === b.thickness. 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 addons/cabinet/lib/cutlist/cutlist.js:86 in sameKind CadCraft
    const sameKind = (a, b) => a.material === b.material && a.thickness === b.thickness && a.length === b.length && a.width === b.width &&

    === in a.width === b.width. 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 addons/cabinet/lib/draw.js:29 in planEnts CadCraft
    for (const f of frontsOf(cab, R).filter((g, i, a) => a.findIndex((h) => h.x === g.x) === i)) out.push(rect(f.x * k, D, f.w * k, F));

    === in h.x === g.x. 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 addons/cabinet/main.js:419 in renderPanel CadCraft
    if (cabs.length) facts = t('panel.facts', { n: cabs.length, pieces: cutList(partsOf(cabs.filter((x) => x.d.u === cabs[0].d.u))).pieces });

    === in x.d.u === cabs[0].d.u. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Cabinets along a wall line.

  • Two computed values addons/cabinetcraft/lib/cutlist/cutlist.js:86 in sameKind CadCraft, BimCraft, ModelCraft, PartCraft
    const sameKind = (a, b) => a.material === b.material && a.thickness === b.thickness && a.length === b.length && a.width === b.width &&

    === in a.thickness === b.thickness. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Cut list sizes, areas and banding lengths.

  • Two computed values addons/cabinetcraft/lib/cutlist/cutlist.js:86 in sameKind CadCraft, BimCraft, ModelCraft, PartCraft
    const sameKind = (a, b) => a.material === b.material && a.thickness === b.thickness && a.length === b.length && a.width === b.width &&

    === in a.width === b.width. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Cut list sizes, areas and banding lengths.

  • Two computed values addons/cabinetcraft/lib/draw.js:29 in planEnts CadCraft, BimCraft, ModelCraft, PartCraft
    for (const f of frontsOf(cab, R).filter((g, i, a) => a.findIndex((h) => h.x === g.x) === i)) out.push(rect(f.x * k, D, f.w * k, F));

    === in h.x === g.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Cabinet plan, elevation, section and 3D boxes.

  • Two computed values addons/cabinetcraft/lib/estimate.js:140 in sheetsFor CadCraft, BimCraft, ModelCraft, PartCraft
    const m = nestJob && nestJob.mats.find((x) => x.material === g.material && x.thickness === g.thickness);

    === in x.thickness === g.thickness. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Cabinet job cost estimate.

  • Two computed values addons/lighting/lib/reports.js:84 in checks CadCraft
    for (let i = 0; i < spans.length; i++) for (let j = i + 1; j < spans.length && spans[j].u === spans[i].u && spans[j].from <= spans[i].to; j++) {

    === in spans[j].u === spans[i].u. 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 addons/windows/lib/cutlist/cutlist.js:86 in sameKind CadCraft
    const sameKind = (a, b) => a.material === b.material && a.thickness === b.thickness && a.length === b.length && a.width === b.width &&

    === in a.thickness === b.thickness. 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 addons/windows/lib/cutlist/cutlist.js:86 in sameKind CadCraft
    const sameKind = (a, b) => a.material === b.material && a.thickness === b.thickness && a.length === b.length && a.width === b.width &&

    === in a.width === b.width. 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 cadcraft.js:506 in rememberView CadCraft
    if (top && top.cx === v.cx && top.cy === v.cy && top.zoom === v.zoom) return;

    === in top.cx === v.cx. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Cursor point and status readouts.

  • Two computed values cadcraft.js:506 in rememberView CadCraft
    if (top && top.cx === v.cx && top.cy === v.cy && top.zoom === v.zoom) return;

    === in top.cy === v.cy. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Cursor point and status readouts.

  • Two computed values cadcraft.js:967 in withNextGhost CadCraft
    if (!was || was.x !== n.x || was.y !== n.y) accessUi?.say(t('access.ghost.next', { what: t('auto.kind.' + n.kind), at: fmtL(n.x) + ', ' + fmtL(n.y) }));   // EG.52: a ghost is said once when it appear

    !== in was.x !== n.x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Cursor point and status readouts.

  • Two computed values cadcraft.js:967 in withNextGhost CadCraft
    if (!was || was.x !== n.x || was.y !== n.y) accessUi?.say(t('access.ghost.next', { what: t('auto.kind.' + n.kind), at: fmtL(n.x) + ', ' + fmtL(n.y) }));   // EG.52: a ghost is said once when it appear

    !== in was.y !== n.y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Cursor point and status readouts.

  • Two computed values dwg/objects-write.js:659 in insertScale CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    else if (sx === sy && sx === sz) { w.BB(2); w.RD(sx); }

    === in sx === sy. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: DWG object values written and read.

  • Two computed values dwg/objects-write.js:659 in insertScale CadCraft, BimCraft, ModelCraft, TakeoffCraft, CivilCraft
    else if (sx === sy && sx === sz) { w.BB(2); w.RD(sx); }

    === in sx === sz. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: DWG object values written and read.

  • Two computed values dwg/table-write.js:71 in insertScale CadCraft, ModelCraft, CivilCraft, DetailCraft, PartCraft
    else if (sx === sy && sx === sz) { w.BB(2); w.RD(sx); }

    === in sx === sy. 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 dwg/table-write.js:71 in insertScale CadCraft, ModelCraft, CivilCraft, DetailCraft, PartCraft
    else if (sx === sy && sx === sz) { w.BB(2); w.RD(sx); }

    === in sx === sz. 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 gds.js:133 in gdsEntities CadCraft
    if (it.k === 'boundary') { if (pts.length > 1 && pts[0].x === pts[pts.length - 1].x && pts[0].y === pts[pts.length - 1].y) pts.pop(); if (pts.length >= 3) ents.push({ type: 'poly', layer: lname, color

    === in pts[0].x === pts[pts.length - 1].x. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: GDSII layout read and placement.

  • Two computed values gds.js:133 in gdsEntities CadCraft
    if (it.k === 'boundary') { if (pts.length > 1 && pts[0].x === pts[pts.length - 1].x && pts[0].y === pts[pts.length - 1].y) pts.pop(); if (pts.length >= 3) ents.push({ type: 'poly', layer: lname, color

    === in pts[0].y === pts[pts.length - 1].y. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: GDSII layout read and placement.

  • 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.x !== c3.x. 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 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.y !== c3.y. 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 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 m3d/earcut.js:161 in findHoleBridge CadCraft, TakeoffCraft
    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: Triangulation of faces with holes.

  • Two computed values m3d/earcut.js:179 in findHoleBridge CadCraft, TakeoffCraft
    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: Triangulation of faces with holes.

  • Two computed values m3d/earcut.js:194 in getLeftmost CadCraft, TakeoffCraft
    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: Triangulation of faces with holes.

  • Two computed values m3d/earcut.js:217 in equals CadCraft, TakeoffCraft
    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: Triangulation of faces with holes.

  • Two computed values m3d/earcut.js:217 in equals CadCraft, TakeoffCraft
    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: Triangulation of faces with holes.

  • Two computed values m3d/earcut.js:247 in middleInside CadCraft, TakeoffCraft
    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: Triangulation of faces with holes.

  • Two computed values m3d/model.js:137 in meshGeometry CadCraft
    if (g && g.v === mesh.v && !mesh.recording) return g.def;

    === in g.v === mesh.v. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Face planes, areas, triangles and solid volume, Drawing an edge: welding, splitting and re-facing, Push/pull, move, stretch, follow me and intersect, Arcs, circles, smooth curves, divide and offset, Dimensions and typed sizes in 3D, Groups, placements and the model file, Welding of imported geometry, Smooth shading and texture placement.

  • Two computed values m3d/model.js:538 in addEdge CadCraft
    if (stops[i].v === stops[i + 1].v) continue;

    === in stops[i].v === stops[i + 1].v. Compare within a documented epsilon scaled to the size of the geometry, or restructure so one side is exact. Reviewed: Face planes, areas, triangles and solid volume, Drawing an edge: welding, splitting and re-facing, Push/pull, move, stretch, follow me and intersect, Arcs, circles, smooth curves, divide and offset, Dimensions and typed sizes in 3D, Groups, placements and the model file, Welding of imported geometry, Smooth shading and texture placement.

  • Two computed values m3d/tools.js:1060 in down CadCraft
    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. Reviewed: 3D drawing and editing tools.