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 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 dwg/table-write.js:70 in insertScale CadCraft, ModelCraft, CivilCraft, DetailCraft, PartCraft
    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. Not in the register.

  • Against 1 dwg/table-write.js:70 in insertScale CadCraft, ModelCraft, CivilCraft, DetailCraft, PartCraft
    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. Not in the register.

  • Against 1 dwg/table-write.js:70 in insertScale CadCraft, ModelCraft, CivilCraft, DetailCraft, PartCraft
    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. Not in the register.

  • Against 1 dwg/table-write.js:72 in insertScale CadCraft, ModelCraft, CivilCraft, DetailCraft, PartCraft
    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. Not in the register.

  • 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 dxf.js:177 in readHeader CadCraft
    else if (varName === '$LTSCALE' && c === 40 && parseFloat(v) > 0 && parseFloat(v) !== 1) out.meta.ltscale = parseFloat(v);

    !== in parseFloat(v) !== 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: objects from the file's text, DXF writing: numbers as text.

  • Against 1 dxf.js:659 in entityFrom CadCraft
    const sz = num(g, 43, 1); if (sz && sz !== 1) add.sz = sz;

    !== 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: DXF reading: objects from the file's text, DXF writing: numbers as text.

  • Against 1 dxf.js:1507 in entity CadCraft
    if ((e.sx ?? 1) !== 1) w(41, f(e.sx)); if ((e.sy ?? 1) !== 1) w(42, f(e.sy)); if (Number.isFinite(e.sz) && e.sz && e.sz !== 1) w(43, f(e.sz)); if (e.rot) w(50, f(deg(e.rot)));

    !== in (e.sx ?? 1) !== 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: objects from the file's text, DXF writing: numbers as text.

  • Against 1 dxf.js:1507 in entity CadCraft
    if ((e.sx ?? 1) !== 1) w(41, f(e.sx)); if ((e.sy ?? 1) !== 1) w(42, f(e.sy)); if (Number.isFinite(e.sz) && e.sz && e.sz !== 1) w(43, f(e.sz)); if (e.rot) w(50, f(deg(e.rot)));

    !== in (e.sy ?? 1) !== 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: objects from the file's text, DXF writing: numbers as text.

  • 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 libpanel.js:194 in search CadCraft
    sayAfterEnd(r.total ? r.total + ' item' + (r.total === 1 ? '' : 's') + (r.total > cards.length ? ', showing ' + cards.length : '') + '.' : t('lib.panel.nothing_found'));

    === in r.total === 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 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 redline.js:46 in readRedline CadCraft
    if (o.v !== 1) return { ok: false, pkg: null, errors: ['version'] };

    !== 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: Redline items placed in the drawing.

  • 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 1 clip.js:49 in readClip CivilCraft
    if (!obj || typeof obj !== 'object' || obj.format !== CLIP_FORMAT || obj.v !== 1 || !Array.isArray(obj.pts)) return null;

    !== in obj.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 dwg/objects-write.js:658 in insertScale DetailCraft, PartCraft
    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. Not in the register.

  • Against 1 dwg/objects-write.js:658 in insertScale DetailCraft, PartCraft
    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. Not in the register.

  • Against 1 dwg/objects-write.js:658 in insertScale DetailCraft, PartCraft
    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. Not in the register.

  • Against 1 dwg/objects-write.js:660 in insertScale DetailCraft, PartCraft
    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. Not in the register.

  • Against 1 dwg/objects-write.js:774 DetailCraft, PartCraft
    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. Not in the register.

  • Against 1 dwg/objects-write.js:818 DetailCraft, PartCraft
    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. Not in the register.

  • Against 1 lib-supply/supply.js:115 in readSupply DetailCraft
    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 1 base-ui.js:580 in scaleFor MarkupCraft
    if (keep) { const s = Math.max(Math.abs(sx === 1 && !grip.key.match(/[ew]/) ? sy : sx), Math.abs(sy === 1 && !grip.key.match(/[ns]/) ? sx : sy)); sx = Math.sign(sx) * s; sy = Math.sign(sy) * s; }

    === in sx === 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 base-ui.js:580 in scaleFor MarkupCraft
    if (keep) { const s = Math.max(Math.abs(sx === 1 && !grip.key.match(/[ew]/) ? sy : sx), Math.abs(sy === 1 && !grip.key.match(/[ns]/) ? sx : sy)); sx = Math.sign(sx) * s; sy = Math.sign(sy) * s; }

    === in sy === 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 clip.js:82 in cleanClip MarkupCraft
    if (!d || typeof d !== 'object' || d.format !== CLIP_FORMAT || d.v !== 1 || !Array.isArray(d.items)) 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: Area markup with cut-outs, and clipboard placement.

  • Against 1 content-clip.js:86 in cleanContentClip MarkupCraft
    if (!d || typeof d !== 'object' || d.format !== CONTENT_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: Carried, stamped and pasted markup geometry.

  • Against 1 markupcraft.js:4498 in recover MarkupCraft
    if (!rec.data?.pdf || !st || st.v !== 1) throw new Error(t('recover.bad'));

    !== in st.v !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Sheet scale, typed lengths and measured values, Markup geometry while drawing and editing, Drawing comparison by vector paths.

  • Against 1 pdf-read.js:146 in fromPrivate MarkupCraft
    if (!d || typeof d !== 'object' || d.v !== 1 || typeof d.type !== 'string' || !TYPES[d.type] || d.type === 'foreign') 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: Annotations and scales read from a PDF.

  • Against 1 records.js:156 in unpackRecords MarkupCraft
    if (!v || typeof v !== 'object' || v.v !== 1 || !Array.isArray(v.records)) return [];

    !== in v.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 mesh/ops.js:773 in splitByPoints ModelCraft
    if (inSplit.has(f) && on.length === 2 && Math.abs(on[0] - on[1]) !== 1 && Math.abs(on[0] - on[1]) !== vs.length - 1) {

    !== in Math.abs(on[0] - on[1]) !== 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: Proportional editing weights and edge creases, Inset, bevel and moves along normals, Subdivide, loop cut, bisect, knife and grid fill, Merge, spin, bridge, slide and smooth.

  • Against 1 model-info.js:58 in cleanTemplate ModelCraft
    if (!v || typeof v !== 'object' || v.v !== 1) return null;

    !== in v.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 nurbs/step.js:302 in trimOf ModelCraft, PartCraft
    let seg = c.deg === 1 ? c.cvs.slice() : Array.from({ length: 33 }, (_, i) => C.point(c, a + (z - a) * i / 32));

    === in c.deg === 1. Fine for a value that is set, not computed (a default scale). If it comes from a calculation, use an epsilon. Reviewed: STEP files of NURBS curves and surfaces.

  • Against 1 skp/messages.js:160 in msg ModelCraft
    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 bodies-ui.js:225 in panel PartCraft
    grid.push(host.check(t('ui.bodies.scale.uniform'), f.uniform, (v) => set(f, t('ui.bodies.undo.uniform'), (g) => { g.uniform = v; if (!v && g.sx === 1 && g.sy === 1 && g.sz === 1) { g.sx = g.s; g.sy = 

    === in g.sx === 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 bodies-ui.js:225 in panel PartCraft
    grid.push(host.check(t('ui.bodies.scale.uniform'), f.uniform, (v) => set(f, t('ui.bodies.undo.uniform'), (g) => { g.uniform = v; if (!v && g.sx === 1 && g.sy === 1 && g.sz === 1) { g.sx = g.s; g.sy = 

    === in g.sy === 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 bodies-ui.js:225 in panel PartCraft
    grid.push(host.check(t('ui.bodies.scale.uniform'), f.uniform, (v) => set(f, t('ui.bodies.undo.uniform'), (g) => { g.uniform = v; if (!v && g.sx === 1 && g.sy === 1 && g.sz === 1) { g.sx = g.s; g.sy = 

    === in g.sz === 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.